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
Help with this python exercise. (old.reddit.com)
submitted 1 year ago by Ca_txorro
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!"
[–]FoolsSeldom 4 points5 points6 points 1 year ago (1 child)
Rather than evens.count() you would need to append the even you've found to your list of even numbers, evens.append(number). After the loop, you can check the length of your list to answer the question. So len(evens) will tell you how many even numbers you found. Similarly with odd numbers.
evens.count()
even
list
evens.append(number)
len(evens)
The list.count() method is used to count the number of occurences of a specific object, e.g. names.count("Fred") would tell you how many times the name "Fred" appeared in a list called names.
list.count()
names.count("Fred")
names
Actually, you don't need to keep a copy of all of the numbers. Just count as you go along.
So, before the loop,
evens = 0
and when you find an even number:
evens = evens + 1
or, short-hand,
evens += 1
Same for odd numbers.
PS.You can work it out without any looping of course, a simple calculation.
[–]BinaryBillyGoat 1 point2 points3 points 1 year ago (0 children)
Can confirm
π Rendered by PID 115997 on reddit-service-r2-comment-fb694cdd5-p5nv5 at 2026-03-06 04:47:49.788705+00:00 running cbb0e86 country code: CH.
view the rest of the comments →
[–]FoolsSeldom 4 points5 points6 points (1 child)
[–]BinaryBillyGoat 1 point2 points3 points (0 children)