Python Game: Restart feature | SoloLearn: Learn to code for FREE!

+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

3/31/2020 3:05:24 AM

sudo-asap

2 Answers

New Answer

+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