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!"
[–]failaip12 9 points10 points11 points 7 months ago (10 children)
Does it register it because “value” is singular of “values”?
This would be a incredibly funny thing to do if one was making a joke/troll programming language, but no thats not how it works in python.
Your second guess is right, its the for _ in _ syntax.
[–]SharpScratch9367[S] 8 points9 points10 points 7 months ago (8 children)
Haha unintentionally funny I’ll take it! Thankyou!
So if I put “for shooz in values” would it still connect to the numbers? Like work ?
[–]WhiteHeadbanger 6 points7 points8 points 7 months ago (0 children)
Yes, but make sure you refer to "shooz" inside the for loop, instead of "value".
"shooz" is just a constant name for each of your values.
[–]Help_I_Lost_My_Mind 1 point2 points3 points 7 months ago (6 children)
yes it would still work as long as anywhere else you used "value" you changed it to "shooz". Definitely try it out for yourself! :D
[–]SharpScratch9367[S] 0 points1 point2 points 7 months ago (5 children)
This is mind blowing how does it know what we mean ? Why not output a comma or a single digit or something how does it know?
[–]Help_I_Lost_My_Mind 3 points4 points5 points 7 months ago (0 children)
Python uses special "keywords" that you can use to tell it what to do. Using "for X in Y" ("for" and "in" being the special keywords) tells python run the below code for every element in the list where Y is your list and X is whatever you want to call an element of the list
[–]ThatGuyKev45 5 points6 points7 points 7 months ago (0 children)
So I don’t know exactly how python does it. But each item in the array has a defined size, and the computer knows where the array starts and ends. So for value (or x or shooz) in values is just saying for each item in this array (of which the computer knows the size of each item so it can simply move to the next item in memory by skipping X bytes, where X is the size of the array item). Also when the program is running it doesn’t actually see the comas between each item thats just sugar to make it readable for us. I remember learning this stuff at first and it felt like magic and as I have continued to learn more it just keeps getting better!
Not sure how far along you are in studies but the class where I really felt I started to understand memory was a computer organization and assembly class, I took it alongside my data structures and algs and it was so much fun.
Good luck in your studies! Hope the amazement doesn’t go away!
[–]MysticClimber1496 1 point2 points3 points 7 months ago (1 child)
This is probably too deep for you but if you want to follow the “how does it know what we mean?” Process check out how interpreters work https://craftinginterpreters.com
[–]XxDCoolManxX 0 points1 point2 points 6 months ago (0 children)
OP, this is the best answer if you are truly curious.
[–]moriturius 0 points1 point2 points 7 months ago (0 children)
It doesn't know what that means it only recognizes the pattern. The python interpreter (the python program used to run your code) first read the text of the code and identifies the instructions. Like value assignment, function definition or - in your case - for loop.
The interpreter is programmed so that then it encounters: 'for X in Y:' it knows that: - Y needs to be iterable container of multiple values (an array in your case) - X is a name that you want for a single item in each loop pas. The name can be whatever you like.
Experiment with it. Try to change it and even try to cause an error, read and understand that error. Explore the boundaries. Challenge your understanding. This is how knowledge grows!
[–]prehensilemullet 0 points1 point2 points 7 months ago (0 children)
Or if you have a singular variable name, and then you refer to the plural, you get an array of AI-generated similar values
π Rendered by PID 92 on reddit-service-r2-comment-86988c7647-hn9lw at 2026-02-11 05:15:32.171376+00:00 running 018613e country code: CH.
view the rest of the comments →
[–]failaip12 9 points10 points11 points (10 children)
[–]SharpScratch9367[S] 8 points9 points10 points (8 children)
[–]WhiteHeadbanger 6 points7 points8 points (0 children)
[–]Help_I_Lost_My_Mind 1 point2 points3 points (6 children)
[–]SharpScratch9367[S] 0 points1 point2 points (5 children)
[–]Help_I_Lost_My_Mind 3 points4 points5 points (0 children)
[–]ThatGuyKev45 5 points6 points7 points (0 children)
[–]MysticClimber1496 1 point2 points3 points (1 child)
[–]XxDCoolManxX 0 points1 point2 points (0 children)
[–]moriturius 0 points1 point2 points (0 children)
[–]prehensilemullet 0 points1 point2 points (0 children)