Rock paper scissors

I tried writing this code for rock paper scissors but it says “sorry, invalid response” no matter what i enter. HELP

try:
    import random
    def main():
        comp=random.randint(0,2)
        user=input("enter either\"rock\" \"paper\" or \"scissors\" : ").lower()
        rock=1
        paper=0
        scissors=2
        if (comp == 1 and user == 0) or (comp == 2 and user==1) or (comp==0 and user ==2):
            print ("YOU WON")
        elif (user is not True ) and (user is not False) and (not user == 2):
            print ("Sorry, invalid response")
            main()
        else:
            print ("Sorry, you lost")
            restart=input ("enter yes if u want to play again: ").lower()
            if restart == ("yes"):
                main()
            else:
                quit()

except:
    print ("something went wrong")
main()

Link to the challenge?
also a code goes between the single “”"

also why not test the code out line by line and see where u get stuck?

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.

markdown_Forums

1 Like

i will fix it and tell you your problem