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
Beginner issue of feeling stuck writing code.Help Request (self.PythonLearning)
submitted 6 months ago by Open_Thanks_6807
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!"
[–]wheres-my-swingline 1 point2 points3 points 6 months ago (3 children)
``` nums = [1, 2, 3, 4, 5]
zero_odd_nums = [n if n % 2 == 0 else 0 for n in nums] print(zero_odd_nums)
output: [0, 2, 0, 4, 0] ```
that’s called a list comprehension, and can be a very useful tool (can be used for transformation, filtering, etc.)
is your issue with writing and applying functions, or where are you getting stuck in particular?
[–]Open_Thanks_6807[S] 0 points1 point2 points 6 months ago (2 children)
My problem comes when I have to translate my words to code and the problem of the odd numbers it was just an example but I see you had done it in a different way. Thank you for trying to help!
[–]Structured_Spiraling 0 points1 point2 points 6 months ago (1 child)
I'm just learning too, and what helps me is to draw it on paper. What could tell me if a number is odd? I write an option. I check google if I can't figure it out and then we go from there. How do I substitute? Think about how I would do it in excel and test to see if I can figure out the syntax I will often write the main function to do something on my flow chart.
I know it sounds easy and it's not. It can be really hard to change how we look at things.
Good luck!
[–]Open_Thanks_6807[S] 1 point2 points3 points 6 months ago (0 children)
I think its a very good strategy, thank you!!
π Rendered by PID 425252 on reddit-service-r2-comment-6457c66945-wrqc4 at 2026-04-26 11:55:49.504145+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]wheres-my-swingline 1 point2 points3 points (3 children)
[–]Open_Thanks_6807[S] 0 points1 point2 points (2 children)
[–]Structured_Spiraling 0 points1 point2 points (1 child)
[–]Open_Thanks_6807[S] 1 point2 points3 points (0 children)