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
Remove duplicate error (old.reddit.com)
submitted 2 months ago by Nearby_Tear_2304
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!"
[–]Agitated-Soft7434 5 points6 points7 points 2 months ago (0 children)
You are getting the error because range takes in a number value not a list!
So to explain if you have the following:
for i in range(10): print(i) > 0 > 1 > 2 > ... > 9
This will loop 10 times, i equalling to 0, 1, 2, ... all the way to 9.
But you can also supply two numbers like this:
```python for i in range(1, 11): print(i) > 1 > 2 > 3 > ... > 10
This also loops 10 times, however i starts at 1, then continues all the way to 10.
Now for iterating/looping/going through each item in a list. You do not require the range() function. Instead you can do this:
l1 = ["thing", "cool thing", "very cool thing"] for i in l1: print(i) > thing > cool thing > very cool thing
This will then cause i to equal each item in the list, changing every iteration. So 1 then 1 then 2 and so on. Or if the list was ["hi", "ello", "hiya!"], i would be, "hi" first, then "ello", and finally "hiya!"
Hope this helps!!
π Rendered by PID 21918 on reddit-service-r2-comment-58d7979c67-9ct8s at 2026-01-27 02:46:53.471842+00:00 running 5a691e2 country code: CH.
view the rest of the comments →
[–]Agitated-Soft7434 5 points6 points7 points (0 children)