Why doesn't this code work? I get an 'expected indented block' error. print("Player died") restart = input('Restart? y/n') if restart in ['y', 'n']: if restart == 'y': # code for y if restart == 'n': # code for n) else: print('typed something else other than y/n') restart
3/29/2020 4:26:43 AM
sudo-asap1 Answer
New AnswerIs this your exact code? If yes, then you cannot have an if statement without any other statements inside. For example: if restart == "y": #code for y if restart == "n": In here, you have no other statement after if statement. Just add a line after if restart == "y": And it will work fine.
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message