I'm trying to create a script that plays the Name Game in text. Got stuck using my first class.
def AskName():
print("\n\nLet's play the Name Game!\n Based on the song written by Shirly Ellis and Lincoln Case.\n")
GivenName = input("What is your first name? --> ")
print("\n")
global GivenName
Call it later on (it's the first class called) and I keep getting this... (Say I entered "David".)
./namegame.py:27: SyntaxWarning: name 'GivenName' is assigned to before global declaration global GivenName Let's play the Name Game! Based on the song written by Shirly Ellis and Lincoln Case. What is your first name? --> David Traceback (most recent call last): File "./namegame.py", line 78, in <module> AskName() File "./namegame.py", line 25, in AskName GivenName = input("What is your first name? --> ") File "<string>", line 1, in <module> NameError: name 'David' is not defined
I had GivenName as not global, and I added the following as suggested on similar issues:
if __name__== "__main__":
AskName()
The error persists.
What am I doing wrong here?