+ 1
Why does it not compare?
4 Antworten
+ 1
Idk py but i can tell what is wrong...
x is the users input and y is the computers choice
U had done
if x == y:
//to do
In js it is like. [This is your code but in js version]
if(x == y){
alert('its a draw')
}
[Correct code in js version]
if(x == 'paper' && y == 'paper'){
alert('its a draw')
}
Now in py....I think there should be an operator that checks of both the conditions are true then execute given code or if not then didnt execute the code
as in js it is && ....sorry idk what it is in py....check course or maybe u already know
(py)
if x == 'paper' (that operator) y == 'paper':
//to do
+ 2
Like this
if x == p and y == p:
print("It's a draw!")
+ 2
Because x ==y is like (assuming player choose paper and computer choose scissor)
'paper' == 'scissor'
As paper is not equal to scissor the code is not executed
+ 1
Can't you do x == y?