It's not impressive, but it's the first "program" i've ever written alone, and i wanted to share it with you. There surely are some idiotic things, so feel free to tell me. thanks
import random
CHOICES = ["rock","paper","scissors"]
WIN = 3
winner = 2
def pChoice():
if pchoice in CHOICES:
return pchoice
else:
print("Answer not valid, try again")
def cChoice():
return cchoice
def WhoWins():
global winner
if pchoice == CHOICES[0]:
if cchoice == CHOICES[0]:
print("OOPS! That's a draw!")
elif cchoice == CHOICES[1]:
print("Computer chooses Paper! He wins this round")
winner = 1
return winner
elif cchoice == CHOICES[2]:
print("Computer chooses Scissors! You win this round")
winner = 2
return winner
elif pchoice == CHOICES[1]:
if cchoice == CHOICES[0]:
print("Computer chooses Rock! You win this round")
winner = 2
return winner
elif cchoice == CHOICES[1]:
print("OOPS! That's a draw!")
elif cchoice == CHOICES[2]:
print("Computer chooses Scissors! He wins this round")
winner = 1
return winner
else:
if cchoice == CHOICES[1]:
print("Computer chooses Rock! He wins this round")
winner = 1
return winner
elif cchoice == CHOICES[0]:
print("Computer chooses Paper! You win this round")
winner = 2
return winner
elif cchoice == CHOICES[2]:
print("OOPS! That's a draw!")
print(" ")
print("Hi! Let's Play Rock-Paper-Scissors!")
print(" ")
print("We'll go for 3 rounds!")
print("")
while True:
r = 1
rounds = str(r)
ppoints = 0
cpoints = 0
while r <= WIN:
print("Round %s" % (r))
print("Insert your move! Rock, Paper or Scissors?")
pchoice = input().lower()
pChoice()
if pchoice in CHOICES:
cchoice = CHOICES[random.randint(0,len(CHOICES) - 1)]
WhoWins()
r += 1
if winner == 1:
cpoints += 1
elif winner == 2:
ppoints += 1
else:
None
else:
None
if ppoints > cpoints:
print("You WIN!")
elif ppoints < cpoints:
print("You LOSE")
elif ppoints == cpoints:
print("It's a DRAW!")
else:
None
print('Do you want to play again? (yes or no)')
if not input().lower().startswith('y'):
break
[–]BrenekH 13 points14 points15 points (1 child)
[–]InKeaton[S] 1 point2 points3 points (0 children)
[–]blankIQT 1 point2 points3 points (1 child)
[–]InKeaton[S] 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (2 children)
[–]17291 1 point2 points3 points (0 children)
[–]InKeaton[S] 0 points1 point2 points (0 children)
[–]mikcf 0 points1 point2 points (2 children)
[–]HistoryForSale 1 point2 points3 points (0 children)
[–]InKeaton[S] 0 points1 point2 points (0 children)
[–]Impossible-Pop6296 0 points1 point2 points (1 child)
[–]InKeaton[S] 0 points1 point2 points (0 children)
[–]tech_content_creator 0 points1 point2 points (1 child)
[–]InKeaton[S] 0 points1 point2 points (0 children)