I am currently trying to practice python So I tried making a Rock paper scissors game where the player is against a computer but I don't understand how to fix my error in the program, can anyone help?
import random import time def main(): print("This is a rock, paper, scissor game") while answer.upper == 'Y': return True return False play_again = True move_list = {'Rock', 'Paper', 'Scissors'} def rps(): print("This is a rock, paper, scissor game") time.sleep(3) move_list = ['Rock', 'Paper', 'Scissors'] while play_again == True: for comp in move_list.keys(): user = input('What\'s your hand?: ') user = user.capitalize() comp = random.choice(list(move_list.keys())) if comp == 'Rock' and user == 'Paper': print("Computer throws " + comp + " you have thrown " + user + "!") print("You Win!") elif comp == 'Rock' and user == 'Rock': print("Computer throws " + comp + " you have thrown " + user + "!") print("It's a draw") elif comp == 'Rock' and user == 'Scissor': print("Computer throws " + comp + " you have thrown " + user + "!") print("You Lose!") elif comp == 'Scissor' and user == 'Paper': print("Computer throws " + comp + " you have thrown " + user + "!") print("You Lose!") elif comp == 'Scissor' and user == 'Rock': print("Computer throws " + comp + " you have thrown " + user + "!") print("You Lose!") elif comp == 'Scissor' and user == 'Scissor': print("Computer throws " + comp + " you have thrown " + user + "!") print("It's a Draw!") elif comp == 'Paper' and user == 'Paper': print("Computer throws " + comp + " you have thrown " + user + "!") print("It's a Draw!") elif comp == 'Paper' and user == 'Rock': print("Computer throws " + comp + " you have thrown " + user + "!") print("You Lose!") elif comp == 'Paper' and user == 'Scissor': print("Computer throws " + comp + " you have thrown " + user + "!") print("You Win!") else: print("You messed up the program dummy") answer = input("Would you like to play again?: ") rps() main()
Error:Traceback (most recent call last):
File "F:\Programing\RPS Game Practice.py", line 62, in <module>
rps()
File "F:\Programing\RPS Game Practice.py", line 17, in rps
for comp in move_list.keys():
AttributeError: 'list' object has no attribute 'keys'