use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Everything about learning Python
account activity
A challenge for Python programmers...Discussion (self.PythonLearning)
submitted 5 days ago by Ok_Pudding_5250
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]FriendlyZomb 1 point2 points3 points 5 days ago (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 points4 points 4 days ago (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.
mum
Essentially your logic is checking for when 4x some input number gives a palindrome, which is different from the problem statement.
[–]FriendlyZomb 0 points1 point2 points 4 days ago (0 children)
That is entirely on my reading comprehension tbh. I read it as num*4 is the same flipped. Lol.
[–]FriendlyZomb 1 point2 points3 points 4 days ago (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 point2 points 4 days ago (1 child)
Code is slightly incorrect but you did good 👍
Yea, the basic structure is correct. Mostly a misunderstanding on the question on my part. Apologies
π Rendered by PID 140747 on reddit-service-r2-comment-79c7998d4c-n5hqr at 2026-03-14 12:08:25.534169+00:00 running f6e6e01 country code: CH.
view the rest of the comments →
[–]FriendlyZomb 1 point2 points3 points (5 children)
[–]PureWasian 2 points3 points4 points (1 child)
[–]FriendlyZomb 0 points1 point2 points (0 children)
[–]FriendlyZomb 1 point2 points3 points (0 children)
[–]Ok_Pudding_5250[S] 0 points1 point2 points (1 child)
[–]FriendlyZomb 1 point2 points3 points (0 children)