0

Need a little help, (rock, paper, scissors program)

I started making (rather figuring out) a rock, paper, scissors program (based off on another guy's example) and I have the issue of when I run the program and I type in: Rock, paper or scissors: rock Rock, paper or scissors: paper I should get: You: -1 , but I always get: You: 1 whatever I change in the program itself (at least changes that I've tried). I would gadly hear suggestions on how to solve this problem and tips (maybe) as to how I could continue and upgrade on the program itself. Thank you all in advance. Here's the program: def game(a,b): human=a comp=b points=0 a=str(input("Rock, paper or scissors: ")) b=str(input("Rock, paper or scissors: ")) if human=="rock" and comp=="paper": human=points-1 print("You: "+str(human)) elif human=="rock" and comp=="scissors": human=points+1 print("You: "+str(human)) elif human=="paper" and comp=="rock": human=points+1 print("You: "+str(human)) elif human=="scissors" and comp=="rock": human=points-1 print("You: "+str(human)) elif human=="paper" and comp=="scissors": human=points-1 print("You: "+str(human)) elif human=="scissors" and comp=="paper": human=points+1 print("You: "+str(human)) elif human!="rock" and human!="paper" and human!="scissors": print("wrong choice, try again") elif comp!="rock" and comp!="paper" and comp!="scissors": print("network error") game("scissors","paper")

20th Jul 2020, 7:02 PM
Helios
Helios - avatar
4 odpowiedzi
+ 2
Nice, it works. Much appriciated. But by the way what was the problem? The only thing I see you've changed was leaving out the unnecessary variables, or was that the problem somehow?
20th Jul 2020, 7:28 PM
Helios
Helios - avatar
+ 2
When you called your function with the variables emplaced, you were asking for a result of Human => scissors Comp => paper You could also remove your input requests from within the def, and place them in the final line. Game(input(), input())
20th Jul 2020, 7:34 PM
Rik Wittkopp
Rik Wittkopp - avatar
+ 1
Oh I get it, originally that part was in the example where I took it from. Didn't really know at the moment what its porpuse was, but I get it now. Thanks✌
20th Jul 2020, 7:38 PM
Helios
Helios - avatar