I can't figure out why the function returns the correct letter when I enter "N" or "n". The function is called but return "None" when I enter the incorrect letter. The function should be keep looping until the correct letter is entered.
This is the output when I enter the correct letter.
(N)ew game
Your choice?: n
Your choice before returning the value to main: n
Your choice: n
This is the output when I enter the incorrect letter.
(N)ew game
Your choice?: j
Wrong input
(N)ew game
Your choice?: n
Your choice before returning the value to main: n
Your choice: None
Source code:
def auswahl():
print("(N)ew game")
choice = input("Your choice?: ")
if choice == 'N' or choice == 'n':
print("Your choice before returning the value to main:", choice)
return choice
else:
print("Wrong input")
auswahl()
#main
eingabe = auswahl()
print("Your choice:", eingabe)