So I was making a simple rock paper scissors game, and I wanted to put it as a function. I also wanted it to loop 10 times before deciding if the user won or lost. But the code just doesn't work and keeps giving random errors.
#code for rock paper scissors
import random
l = ["rock","paper","scissors"]
def rps():
q = 0
wincount = 0
while q < 10:
w = random.choice(l)
x = input("Choose rock paper or scissors all lowercase: ")
if w == "rock":
if x == "rock":
print("It's a draw")
if x == "paper":
print("You lost :(")
if x == "scissors":
print("You win!")
wincount += 1
elif w == "paper":
if x == "rock":
print("You lost :(")
if x == "paper":
print("It's a draw")
if x == "scissors":
print("You win!")
wincount += 1
elif w == "scissors":
if x == "rock":
print("You win!")
wincount += 1
if x == "paper":
print("You lost :(")
if x == "scissors":
print("It's a draw")
q += 1
if wincount >= 5:
print("You won the game!")
The error is
PS D:\project percy> & C:/Users/Dell/AppData/Local/Programs/Python/Python39/python.exe "d:/project percy/cogs/asiufysduifhi.py"
PS D:\project percy> rps()
At line:1 char:5
+ rps()
+ ~
An expression was expected after '('.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordE
xception
+ FullyQualifiedErrorId : ExpectedExpression```