问题
So this is the basic string (the text is in hungarian before you are wondering):
>>> nev=input("add meg a neved: ")
add meg a neved: Kristóf
>>> print("Üdvözöllek, " + nev)
Üdvözöllek, Kristóf
>>> print("egy út előtt állsz")
egy út előtt állsz
>>> print("elindulsz rajta")
elindulsz rajta
>>> arany: 0
>>> print("Most" + str(arany)+ "aranyad van")
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
print("Most" + str(arany)+ "aranyad van")
NameError: name 'arany' is not defined
The error message claims that the name is not defined, even though I gave it a value in the IDE, and I just cannot figure out what exactly did i wrote wrong...
any help would be greatly appreciated
回答1:
It should be arany = 0
, not arany: 0
- I'm not sure why that's even valid.
来源:https://stackoverflow.com/questions/48336724/name-error-not-defined-in-python