+ 1

# rock paper scissor

this code get user input of two player how many times they can use paper , rock , scissor and in output I should output what is the maximum score for second one. per time he wins get one score and per time he lose , he will lose one score. why doesn't this code work? numbers = [int(i) for i in input('').split(' ')] def shingedbow(): for i in range(numbers): return "paper" for i in range(numbers): return "rock" for i in range(numbers): return "scissor" def friend(): for i in range(numbers): return "scissor" for i in range(numbers): return "paper" for i in range(numbers): return "rock" n = sum(numbers[0:3]) results1 = [] results2 =[] counter = 0 for i in range(n): results1.append(shingedbow()) results2.append(friend()) def check_rps(a,b): if (a=="rock" and b=="scissor") or (a=="scissor" and b=="paper") or (a=="paper" and b=="rock"): return 1 elif (b=="rock" and a=="scissor") or (b=="scissor" and a=="paper") or (b=="paper" and a=="rock"): return 2 elif (a=="rock" and b=="rock") or (a=="scissor" and b=="scissor") or (a=="paper" and b=="paper"): return 3 return counter #def travers(): counter = 0 for i in results1: check_answer=(check_rps(i,results2[results1.index(i)])) #print(check_answer) if check_answer==1: counter-=1 elif check_answer==2: counter+=1 elif check_answer==3: counter+=0 print(counter)

1st Mar 2022, 11:51 AM
shokin touch 