Facing Problem in Executing Rock , papers , scissors game . need help in python
` '''This code is not giving error but i dont know why the "comp" value is always none. its not changing even through random module and its functions . please help me ''' import random
def game(comp , player):
if player == comp:
return None
elif comp == "r":
if player == "s":
return False
elif player == "p":
return True
elif comp == "s":
if player == "p":
return False
elif player == "r":
return True
elif comp == "p":
if player == "r":
return False
elif player == "s":
return True
comp = print("Comp Turn: Rock , Papers, Scissors: ") randNo = random.randint(1 , 3) if randNo == 1: comp == "r" elif randNo == 2: comp == "p" elif randNo == 3: comp == "s"
player = input("Your Turn: Rock(r) , Papers(p) , Scissors(s) : ")
result = game( comp , player)
print("Computer chose" , comp) print("You chose`" , player)
if result == None: print("The game is tied") elif result: print("You Won") else: print("You Lose")
''' the "comp" value is showing none type, i want it to be str. i tried converting it but it not worked plzzz help masters. anyone professional here to help`'''
This is very simple mistake which beginner will always end up with.
if randNo == 1: comp == "r" elif randNo == 2: comp == "p" elif randNo == 3: comp == "s"
here use single = for assignment of values instead of ==..