import random print("Ready to play rock, paper, scissors?!") print("When prompted, please select one of the three options: rock, paper, or scissors. The program will randomly pick one and will display the results") user=raw_input("Please pick either rock, paper, or scissors") comp=rand() user=1 if user<comp: print("You lose!") elif user>comp: print("You win!") elif user==comp: print("Tie!") #if user.lower()=="rock": def rand() comp=random.randInt(1,3) return comp1 #win(user, comp2), return string user win/lose def win(str1=str,str2=str) if str1=="rock": if str2=="rock": return "Tie!" elif str2=="paper": return "You lose!" elif str2=="scissors": return "You win!" if str1=="paper": if str2=="rock": return "You win!" elif str2=="paper": return "You lose!" elif str2=="scissors": return "You win!"
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question