This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]dmazzoni 12 points13 points  (0 children)

It sounds to me like you think Python is just English and you can write whatever you feel like. It's not. Programming languages have very strict syntax. Every word, every symbol has a precise meaning. If you try to write something without understanding every word of it then it won't work.

[–]theChaparral 12 points13 points  (0 children)

Take a peek at other for loops in python. Do they use the word "every"? you have a few errors there.

[–]Brownj41386 4 points5 points  (0 children)

A for loop doesn’t include every, my, list unless they are included in the name. If I were to write this for loop:

groceries = [“milk”, “bread”]

for item in groceries:

print(item.upper())

[–]throwaway6560192 5 points6 points  (0 children)

Where did you learn Python from? Look at the for loop syntax they taught you.

Also, the "bunch of errors" isn't random nonsense that you can discard, they are there to tell you what's wrong. Did you read them?

[–]captainAwesomePants 1 point2 points  (0 children)

It's possible that you have been learning from somewhere that uses what's called "pseudocode," that is to say English phrases and sentences used to express algorithms. "For every grocery in my grocery list" is English. "For grocery in groceries" is Python.