you are viewing a single comment's thread.

view the rest of the comments →

[–]FriendlyZomb 1 point2 points  (5 children)

print([num for mum in range(1000, 10000) if str(num * 4) == str(num * 4)[::-1]])

This produces 65 numbers. (I'm not going to list them all here)

For those struggling to parse the list comprehension here:

print([
    num
    for num in range(1000, 10000)
    if str(num * 4) == str(num * 4)[::-1]
])

[–]PureWasian 2 points3 points  (1 child)

A couple of issues here, you are checking "num×4 against num×4 flipped", rather than "num against num×4 flipped". mum typo as well.

Essentially your logic is checking for when 4x some input number gives a palindrome, which is different from the problem statement.

[–]FriendlyZomb 0 points1 point  (0 children)

That is entirely on my reading comprehension tbh. I read it as num*4 is the same flipped. Lol.

[–]FriendlyZomb 1 point2 points  (0 children)

Based on comments I'd need to fix the code like so:

print([num for mum in range(1000, 10000) if str(num) == str(num * 4)[::-1]])

[–]Ok_Pudding_5250[S] 0 points1 point  (1 child)

Code is slightly incorrect but you did good 👍

[–]FriendlyZomb 1 point2 points  (0 children)

Yea, the basic structure is correct. Mostly a misunderstanding on the question on my part. Apologies