-
-
Save tarunbod/edd70f4f16466b01b455a36597f00805 to your computer and use it in GitHub Desktop.
rock paper scissors in python for practice.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
def computerChoice(): | |
random.seed() | |
a = random.randint(1,3) | |
choices = ["rock", "scissors", "paper"] | |
return choices[a - 1] ''' if a is 1, it'll return choices[0] which is rock, etc. ''' | |
''' | |
if(a == 1): | |
computer = "rock" | |
elif(a == 2): | |
computer = "scissors" | |
elif(a == 3): | |
computer = "paper" | |
return computer | |
''' | |
b = 1 | |
while(b == 1): | |
print("How many times do you wish to play?") | |
play = int(input()) | |
for i in range (0, play): ##Note to self: this is correct because python excludes the stop range. For instance if I enter 3, it will go 0,1,2 | |
print("type either rock, paper, or scissors.") | |
user = input().lower() | |
cc = computerChoice() | |
''' | |
Bro, just check if the user input and the computerChoice are equal | |
not all this shit | |
# if(user.lower() == "rock" and computerChoice() == "rock"): | |
# print("tie") | |
# elif (user.lower() == "scissors" and computerChoice() == "scissors"): | |
# print("tie") | |
# elif (user.lower() == "paper" and computerChoice() == "paper"): | |
# print("tie") | |
''' | |
if user == cc: | |
print("tie") | |
elif (user.lower() == "rock" and computerChoice() == "scissors"): | |
print("win") | |
elif (user.lower() == "scissors" and computerChoice() == "paper"): | |
print("win") | |
elif (user.lower() == "paper" and computerChoice() == "rock"): | |
print("win") | |
elif (user.lower() == "scissors" and computerChoice() == "rock"): | |
print("lose") | |
elif (user.lower() == "paper" and computerChoice() == "scissors"): | |
print("lose") | |
elif (user.lower() == "rock" and computerChoice() == "paper"): | |
print("lose") | |
print("if you wish to continue type 1 but if not type any other number") | |
b = (int)(input()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
removed semicolons, compacted code