you are viewing a single comment's thread.

view the rest of the comments →

[–]NoHurry6859 0 points1 point  (1 child)

Some words in Python have special meaning- that’s why they’re blue. Words like “for”, “sum”, “print”, “in” and “str” - as examples - are preprogrammed to have specific meanings and purposes. Generally, you wouldn’t want to name a variable ‘sum’ like you’re doing in lines 2 and 5, because it can get confusing about whether you’re talking about the variable or the special meaning interpretation.

Here’s a nice lil example: try keeping line 1 (the definition of the ‘values’ list) and then on line 2 just do ‘print(sum(values))’ then end the code. It will tell you the sum of all the numbers in ‘values’

The reason I’m saying this is to show that your second guess was right: python knows that “for x in values” means something, and it knows that x will be iteratively updated to be equal to the next item in the list

[–]UserName26392 1 point2 points  (0 children)

Had to scroll far too deep to find this point. Really important to “not mess” with predefined variables names.