+ 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

31st Mar 2020, 3:05 AM
sudo-asap
sudo-asap - avatar
2 ответов
+ 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
31st Mar 2020, 3:11 AM
Gordon
Gordon - avatar
0
Thank you Gordon
1st Apr 2020, 7:27 PM
sudo-asap
sudo-asap - avatar