Can someone explain to me whats wrong with this code, It is saying that scissors is not defined but i thought it was.. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can someone explain to me whats wrong with this code, It is saying that scissors is not defined but i thought it was..

import random print('Rock, paper, or scissors?') rps = ['rock', 'paper', 'scissors'] compGuess = random.choice(rps) tie = ('Sorry, its a draw') win = ('You\'ve won, Nice job!') lose = ('You\'ve lost. Please play again!') guess = str(input()) if guess == scissors and compGuess == scissors: print(tie) elif guess == scissors and compGuess == paper: print(win) elif guess == scissors and compGuess == rock: print(lose) elif guess == rock and compGuess == rock: print(tie) elif guess == rock and compGuess == scissors: print(win) elif guess == rock and compGuess == paper: print(lose) elif guess == paper and compGuess == paper: print(tie) elif guess == paper and compGuess == rock: print(win) elif guess == paper and compGuess == scissors: print(lose)

25th May 2017, 11:30 PM
SoakedInAllan
SoakedInAllan - avatar
3 Answers
+ 2
you should enclose string with ''
25th May 2017, 11:39 PM
Damon RealMen
Damon RealMen - avatar
+ 1
what do you mean? @Damon RealMen
25th May 2017, 11:59 PM
SoakedInAllan
SoakedInAllan - avatar
+ 1
nevermind I figured it out, such a beginner error!
26th May 2017, 12:03 AM
SoakedInAllan
SoakedInAllan - avatar