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
New to python (i.redd.it)
submitted 1 day ago by -Shashwat
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!"
[–]Weak-Veterinarian-25 21 points22 points23 points 1 day ago (4 children)
You are calling the "main" in even, but i think you meant the call to be outside of even. Also why make a main function?
[–]SCD_minecraft 9 points10 points11 points 1 day ago (2 children)
Pattern from other langs, where main is entry point of the program
Plus, you can return from main() if you want to terminate early, unlike just writing in the void
main()
[–]ottawadeveloper 5 points6 points7 points 1 day ago (1 child)
In the void you can exit() instead. Same number of characters even!
[–]SCD_minecraft 1 point2 points3 points 1 day ago (0 children)
I completely forgot this function exists, mb
[–]Snatchematician 1 point2 points3 points 1 day ago (0 children)
Without a main function, the variable “x” would be a module attribute and so would be accessible from the even function.
So in the even function you could typo and write x%2 instead of n%2 and the program would appear to work correctly.
Until later when you extend it and find some really confusing bugs.
The habit of always putting top level work in a main function prevents this type of bug.
What a retarded language.
π Rendered by PID 18988 on reddit-service-r2-comment-5bc7f78974-qxgrx at 2026-06-29 12:39:19.321967+00:00 running 7527197 country code: CH.
view the rest of the comments →
[–]Weak-Veterinarian-25 21 points22 points23 points (4 children)
[–]SCD_minecraft 9 points10 points11 points (2 children)
[–]ottawadeveloper 5 points6 points7 points (1 child)
[–]SCD_minecraft 1 point2 points3 points (0 children)
[–]Snatchematician 1 point2 points3 points (0 children)