1

There is an error on line 15 - it expected an indented block but I don't understand why

if p1 == p2:
    print ("Draw, Try again")
    time.sleep(1)
    file = 'RPS.py'
    os.startfile(file)
    exit()
elif (p1=="Rock" and p2=="Scissors")or(p1=="Scissors"and p2=="Paper")or(p1=="Paper"and p2=="Rock"):
    print ("Player 1 Wins")
    while a==2:
        end=input
        if end== "END":
            exit()
        else:
            #           
elif (p2=="Rock" and p1=="Scissors")or(p2=="Scissors"and p1=="Paper")or(p2=="Paper"and p1=="Rock"):
    print("Player 1 Wins")
    while a==2:
        end=input
        if end== "END":
            exit()
        else:
            #
else:#

The error message said it "expected an indented block" and highlights the end of line 15

James
  • 11
  • 2

3 Answers3

2

Put pass there, because Python's syntax expects something to be there, in layman's terms. Or, even better, omit the else part completely if it doesn't do anything.

plamut
  • 3,085
  • 10
  • 29
  • 40
1

you can not use # as pass statement. use pass.

# are just comments and have no syntactical function.

hiro protagonist
  • 44,693
  • 14
  • 86
  • 111
0

I will mark lines with #remove you should remove because they do nothing. Or you can put pass in there as other says but removal is better option.

This error means that after else it expect to be something there but there is nothing.

You don't have to have else or elif before if. (You only have to have if before else or elif if you want to use else or elif).

if p1 == p2:
    print ("Draw, Try again")
    time.sleep(1)
    file = 'RPS.py'
    os.startfile(file)
    exit()
elif (p1=="Rock" and p2=="Scissors")or(p1=="Scissors"and p2=="Paper")or(p1=="Paper"and p2=="Rock"):
    print ("Player 1 Wins")
    while a==2:
        end=input
        if end== "END":
            exit()
        else: #remove
            # #remove
elif (p2=="Rock" and p1=="Scissors")or(p2=="Scissors"and p1=="Paper")or(p2=="Paper"and p1=="Rock"):
    print("Player 1 Wins")
    while a==2:
        end=input
        if end== "END":
            exit()
        else: #remove
            # #remove
else:# #remove
Brambor
  • 604
  • 1
  • 8
  • 25