Is this what you want?
def existingPlayers(name, players):
'''
Check if player name already exists
'''
for player in players:
if player[0].lower() == name.lower():
return True
return False
def getPlayerNames(players):
'''
Get the names of the players. Check if the number of players and
player names are valid
'''
while True:
name = input("Enter player name or <ENTER> to exit (min 2, max 4 players):")
if len(name) == 0:
if len(players) < 2:
print(f"Minimum 2 players. Currently, {len(players)} player")
continue
else:
break
if existingPlayers(name, players):
print("Repeated name. Choose another name")
continue
players.append([name])
if len(players) == 4:
break
def main():
players = []
getPlayerNames(players)
main()
2
solved NameError: variable is not defined [closed]