我为学校建立了这个程序。它仍在进行中,但我在路上碰到了一个肿块,我说他把我的头发扯掉了。
我已经尝试过更改我的变量,它们是如何设置的,以及我想不出的任何东西都非常烦人。我也不能让它成为我的图表,但这不是我的首要任务。
def compare(u1, u2):
if u1 == u2:
return("It's a tie!")
TIE = TIE +1
elif u1 == 'rock':
if u2 == 'scissors':
return("{0} wins with Rock!".format(user1))
u1WIN +1
else:
return("{0} wins with Paper!".format(user2))
u2WIN +1
elif u1 == 'scissors':
if u2 == 'paper':
return("{0} wins with scissors!".format(user1))
u1WIN +1
else:
return("{0} wins with rock!".format(user2))
u2WIN +1
elif u1 == 'paper':
if u2 == 'rock':
return("{0} wins with paper!".format(user1))
u1WIN +1
else:
return("{0} wins with scissors!".format(user2))
u2WIN +1
else:
return("Invalid input! some one has not entered rock, paper or scissors, try again.")
sys.exit()
#this is so frustrating! i cant get my variables to change!
#the winner should be getting points, but they arent. and its so annoying!! it always returns 0 no matter what. i am about this || close to giving up on it.
x = 0
u1WIN = x
u2WIN = x
TIES = x
play = 3
while play >= 0:
if play == 0:
break
else:
user1_answer = getpass.getpass("{0}, do you want to choose rock, paper or scissors? ".format(user1))
user2_answer = getpass.getpass("{0}, do you want to choose rock, paper or scissors? ".format(user2))
print(compare(user1_answer, user2_answer))
play = play +-1
print('player 1\'s wins', u1WIN)
print ('player 2\'s wins', u2WIN)
print('number of ties', TIES)
user_scores = [u1WIN, u2WIN, TIES]
wins = ['user1', 'user2', 'ties']
colors = ['blue', 'green', 'red']
plt.pie(user_scores, labels=wins, colors=colors, startangle=90, autopct='%.1f%%')
plt.show()
i expected to get an output that matches the amount of times won, unfortunately, it always comes out as 0