Python SyntaxError: invalid syntax [elif my_move == 'rock']

Question:

I’m developing a rock paper scissors on python and I’m getting this syntax error
any help is appreciated

class Player:
def move(self):
    return 'rock'

def learn(self, my_move, their_move):
    self.my_move = my_move
    self.their_move = their_movee here

class Game:
def __init__(self, p1, p2):
    self.p1 = p1
    self.p2 = p2

def play_round(self):
    move1 = input("Pick something!n")
    move2 = self.p2.move()
    print(f"Player 1: {move1}  Player 2: {move2}")
    self.p1.learn(move1, move2)
    self.p2.learn(move2, move1)
    my_score = 0 
    computer_score = 0
    if beats(move1, move2):
        my_score = my_score + 1
        print ("You win")
        print ("Human score = " + str(my_score) + " "  + "Computer score = " + str(computer_score) ) 
    elif beats(move2,move1):
        computer_score = computer_score + 1
        print ("Computer wins")
        print ("Human score = " + str(my_score) + " "  + "Computer score = " + str(computer_score) ) 
    else:
        print ("Draw")
        print ("Human score = " + str(my_score) + " "  + "Computer score = " + str(computer_score) )    

def play_game(self):
    print("Game start!")
    for round in range(3):
        print(f"Round {round}:")
        self.play_round()
    print("Game over!")

class cycleplayer(Player):
def move(self):
    if round == 0 :
        return 'rock'

    elif  self.my_move == 'rock'
        return "paper"   

    elif self.my_move == 'paper'
        return "scissors"  

    else self.my_move == 'scissors'
        return "rock"

on the cycleplayer subclass I want the program to take the previous move and use it in the current round

I get an error on the first elif in the subclass cycleplayer
the error points on "rock"

invalid syntax ()

Asked By: Krushyada

||

Answers:

In addition to the missing colons after your elif’s and the disallowed condition following else, this might have an issue because of the white space. Be sure to indent the member functions within your classes!

Answered By: Charles Tapley Hoyt
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.