Python Ex7 syntax error keyword can't be an expression

I have typed Zed’s code like this

print(“Mary had a little lamb.”)
print(“Its fleece was white as {}.”.format(‘snow’))
print(“And everywhere that Mary went.”)
print("." * 10) #what did that do?

end1 = “C”
end2 = “h”
end3 = “e”
end4 = “e”
end5 = “s”
end6 = “e”
end7 = “B”
end8 = “u”
end9 = “r”
end10 = “g”
end11 = “e”
end12 = “r”

#watch that comma at the end. try removing it to see what happens
print(end1 + end2 + end3 + end4 + end5 + end6 + end=’ ')
print(end7 + end8 + end9 + end10 + end11 + end12)

And I keep getting this error message (wirh or without the comma)
PS C:\Users\setup\lpthw> python ex7.py
File “ex7.py”, line 20
print(end1 + end2 + end3 + end4 + end5 + end6, + end=’’)
^
SyntaxError: keyword can’t be an expression
PS C:\Users\setup\lpthw> python ex7.py
File “ex7.py”, line 20
print(end1 + end2 + end3 + end4 + end5 + end6 + end=’’)
^
SyntaxError: keyword can’t be an expression

You have this line:

print(end1 + end2 + end3 + end4 + end5 + end6, + end=’’)

But there is no plus before end=’’ so change it to this:

print(end1 + end2 + end3 + end4 + end5 + end6, end=’’)

Thanks, that is so obvious once you point it out. I did read it backwards multiple times, but did not see it. Practice, practice, practice.

You wouldn’t believe how frustrating single character errors are. I’ve been blocked for weeks because of a stray quote or a single misspelled word.

Hi, but what does this line mean exactly?
SyntaxError: keyword can’t be an expression

They’re saying you can use the keyword “print” in an expression, but really that message is totally useless. What causes it is the end of the line:

end + end="")

Which confuses Python and it keeps on reading it into the next line. So, Python thinks you actually typed this:

end + end="")print(end

Which is meaningless garbage, and then python just gives up and tells you a garbage error. The solution is simple though:

end, end="")

See the comma? That’s all.