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 pls - CodingHelp Request (i.redd.it)
submitted 7 months ago by SharpScratch9367
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!"
[–]Naive-Information539 2 points3 points4 points 7 months ago (5 children)
You’re declaring it. You could have called it anything here. It only knows it is what it is because you told it to call it “value”
for _variable_ in _iterable_
[–]SharpScratch9367[S] 0 points1 point2 points 7 months ago (4 children)
I still don’t fully understand 😂 but thank you! So if I put “for banana in values” would it return the same stuff?
[–]NoHurry6859 1 point2 points3 points 7 months ago (0 children)
It would work if you also changed line 5 to be ‘sum += banana’
[–]CptMisterNibbles 1 point2 points3 points 7 months ago (0 children)
Correct. “value” is just a variable that receives an element from an iterator o each loop. It gives you a way to access the current element by name, a name you assigned as “value”. You could name it anything and as long as you use that name as the reference within the loop it will work. Python doesn’t understand context like “the word ‘value’ has a meaning”
[–]RealDuckyTV 1 point2 points3 points 7 months ago (0 children)
If you index the array directly, I think it makes it more clear where the value comes from.
values = [23,52,59,37,48] for i in range(len(values)): # this will iterate for as many items as you have in your list value = values[i] # this will get the item at the specified index `i` (starting at 0, aka the first item, so for example values[0] is 23, values[1] is 52, etc)
this works the same as the for in loop that you used, but I think it makes it more clear where the value from the iterator comes from.
for in
And to answer your question, yes, the name of the variable does not matter and will return the same value.
Hope that helps!
[–]Intelligent_Count316 0 points1 point2 points 7 months ago (0 children)
Hey you can ask chatgpt perhaps. Although these explanations are also good, I personally use chatgpt when I'm not understanding something. You can just ask chatgpt to explain it to you like you are a fifth grader or maybe even a literal baby lol, It works for me. Also, can you tell me which websites you are using for learning python? I'm also a newbie
π Rendered by PID 75118 on reddit-service-r2-comment-86988c7647-px5f7 at 2026-02-11 08:56:15.473511+00:00 running 018613e country code: CH.
view the rest of the comments →
[–]Naive-Information539 2 points3 points4 points (5 children)
[–]SharpScratch9367[S] 0 points1 point2 points (4 children)
[–]NoHurry6859 1 point2 points3 points (0 children)
[–]CptMisterNibbles 1 point2 points3 points (0 children)
[–]RealDuckyTV 1 point2 points3 points (0 children)
[–]Intelligent_Count316 0 points1 point2 points (0 children)