+ 1
Python Game: Restart feature
What's the proper way to write this code? y/n returns 'typed something else print("Player died") restart = input('Restart? y/n') if restart in ['y', 'n']: if restart == 'y': print('Restart is y') if restart == 'n': print('Restart is n') while restart != 'y' or 'n': print('typed something else other than y/n') restart = input('Restart? y/n') if restart in ['y', 'n']: if restart == 'y': print('Restart is y') break if restart == 'n': print('Restart is n') break
2 Answers
+ 3
Because your while condition already stops at restart being y or n, you don't need those if else.
just print input
https://code.sololearn.com/cpiQNKm5j1LD/?ref=app
0
Thank you Gordon