I am writing a simple team picker program and I keep getting this error message:
NameError: name 'y' is not defined
My code works in online python interpreters so i am not sure if is my code or the text editor that i am using which is atom.
Screenshot of my code:
This code should work
players = []
while input('Would you like to add players to your team? Y/N').lower() == 'y':
name = input('What is the players name?')
players.append(name)
print(f'You have {len(players)} players on your team')
You need to call lower
(like lower()
) to actually get the lowercase answer, not the function lower
. Also I moved the add player input to the while loop to make it more clean.