Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Facing Problem in Executing Rock , papers , scissors game . need help in python #11

Open

Description

`
'''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`'''

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /