I am currently working on a Yahtzee game written in Python 3.5. I have defined a function that asks the user to type in the names of the people who will be playing, before checking if this is correct.
def get_player_names():
while True:
print("Who are playing today? ")
players = [str(x) for x in input().split()]
n = len(players)
if n == 1:
for p in players:
print("So", p, "is playing alone today.")
choice = input("Is this correct?(y/n)\n")
if choice == "y" or "Y":
break
elif choice == "n" or "N":
continue
else:
print("You should enter either y/Y or n/N")
continue
elif n > 1:
print("So today, ", n, " people are playing, and their names are: ")
for p in players:
print(p)
choice = input("Is this correct?(y/n)\n")
if choice == "y" or "Y":
break
elif choice == "n" or "N":
continue
else:
print("You should enter either y/Y or n/N")
continue
else:
print("Sorry, but at least one person has to participate")
continue
placeholder()
def placeholder():
print("KTITENS")
get_player_names()
The program creates the list of players without a problem, as well as when the user confirm that the names of the players are correct, at which point the loop breaks and the next function is called. (Which is currently just a function that prints KITTENS. The problem is that if the user enters "n"/"N" or something else, I would like the loop to repeat, but it breaks instead.
Hopefully someone can assist me! Apologies if this question is a duplicate, but I couldn't find a similar question concerning Python 3.