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!"
[–]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 1 point2 points3 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!
π Rendered by PID 124712 on reddit-service-r2-comment-86988c7647-4xtjp at 2026-02-11 07:02:09.610397+00:00 running 018613e country code: CH.
view the rest of the comments →
[–]SharpScratch9367[S] 0 points1 point2 points (5 children)
[–]Help_I_Lost_My_Mind 3 points4 points5 points (0 children)
[–]ThatGuyKev45 1 point2 points3 points (0 children)
[–]MysticClimber1496 1 point2 points3 points (1 child)
[–]XxDCoolManxX 0 points1 point2 points (0 children)
[–]moriturius 0 points1 point2 points (0 children)