DandyPotato DandyPotato - 2 months ago 9
Python Question

PYTHON: Expected an indented block, cant find out where or why

I can't seem to figure out why my program won't run. It keeps saying expected an indented block I tried going back making sure I didn't indent too many times or too little but I can't seem to find the problem. Can anyone help? Please and thank you.

import random

userChoice = eval(input("Scissor (0), Rock (1), Paper (2)"))

computerChoice = random.randint(0,2)
if computerChoice == 0:
elif computerChoice == 1:
elif computerChoice == 2:

if userChoice == 0:
elif userChoice == 1:
elif userChoice == 2:

if userChoice == 0 and computerChoice == 0:
print("The computer is Scissors. You are Scissors. It's a tie!")
elif userChoice == 0 and computerChoice == 1:
print("The computer is Rock. You are Scissors. You lost")
elif userChoice == 0 and computerChoice == 2:
print("The computer is Paper. You are Scissors. You won!")

if userChoice == 1 and computerChoice == 0:
print("The computer is Scissors. You are Rock. You won!")
elif userChoice == 1 and computerChoice == 1:
print("The computer is Rock. You are Rock. It's a tie!")
elif userChoice == 1 and computerChoice == 2:
print("The computer is Paper. You are Rock. You lost")

if userChoice == 2 and computerChoice == 0:
print("The computer is Scissors. You are Paper. You lost")
elif userChoice == 2 and computerChoice == 1:
print("The computer is Rock. You are Paper. You won!")
elif userChoice == 2 and computerChoice == 2:
print("The computer is Paper. You are Paper. It's a tie!")

Answer

There needs to be a body to those empty if/elif statements

Example (python 2 style):

if computerChoice == 0:
    print 'Something needs to be done here'
elif computerChoice == 1:
    print 'Something needs to be done here too'
elif computerChoice == 2:
    print 'And something needs to be done here, too'

Obviously replace those print statements with some implementation of what you are trying to do. But there cannot be nothing there.

Exception - a pass statement is acceptable if you really want to do nothing.

if computerChoice == 0:
    pass # do nothing here
elif computerChoice == 1:
    pass # do nothing here
elif computerChoice == 2:
    pass # do nothing here