Feb-22-2021, 05:33 PM
Hey guys,
im currently just trying to make very basic rock, paper, scissors game but i strumbled upon the following problem:
i wrote basic code to play Rock, Paper, Scissors. After every round i call the
Heres my Code:
im currently just trying to make very basic rock, paper, scissors game but i strumbled upon the following problem:
i wrote basic code to play Rock, Paper, Scissors. After every round i call the
playagain()
function to ask the user, if he wants to play again. If he does, i want the code to start over again.Heres my Code:
import random # user input # random cpu for R,S,P # compare results # print winner # Ask to play again def playagain(): print("do you want to play again?") choose = input("Yes or No?") choose = choose.upper() if choose == "YES": print("a") # THE PROBLEM IS HERE: IF THE USER INPUT EQUALS "YES", THEN START FROM THE BEGINNING else: exit() # cpu options to randomly choose options = ["R", "P", "S"] cpu = [i for i in random.choice(options)] cpu = cpu[0] user = input("Choose [R]ock, [P]aper or [S]cissors: ").upper() # What if user gives wrong input? while user not in options: user = input("Choose [R]ock, [P]aper or [S]cissors: ").upper() if cpu == user: print("Draw!") elif user == "R" and cpu == "S": print("You Win!") playagain() elif user == "R" and cpu == "P": print("Fucking looser. You Suck!") playagain() elif user == "P" and cpu == "R": print("You Win!") playagain() elif user == "P" and cpu == "S": print("you fucking suck!") playagain() elif user == "S" and cpu == "R": print("you suck!") playagain() elif user == "S" and cpu == "P": print("You Win!") playagain()thanks ahead!
