I'm learning Python and I'm trying to create a football simulator and when I input a team name, it gives me a name '' not defined error
. I'm coding on terminal with python 2.7:
import time
import random
print("Welcome to The Football Simulator v1.0!")
team1 = input('Enter the first team ')
team2 = input('Enter the second team ')
venue = input('Where are they playing ')
print('Simulating...')
time.sleep(5)
def determineScore() :
x = random.randint(1,10)
if x <= 9:
y = random.randint(1,6)
if y <= 2:
score = 0
elif y <= 4:
score = 1
elif y == 5:
score = 2
elif y == 6:
score = 3
elif x == 10:
score = random.randint(1,5)
return score
team1Score = determineScore()
team2Score = determineScore()
print("==============RESULT==============")
print(team1, ' ',team1Score)
print(team2, ' ',team2Score)
Now I'll show you the error:
Welcome to The Football Simulator v1.0!
Enter the first team: barcelona
Traceback (most recent call last):
File "footballsimulator.py", line 4, in <module>
team1 = input("Enter the first team: ")
File "<string>", line 1, in <module>
NameError: name 'barcelona' is not defined.
Also, if I give it a name with space it says unexpected EOF
.
Strangely, it works with numbers.
If I've made an eggheaded mistake, forgive me because I just started python and I'm only 13.