不知道这里出了什么问题

时间:2019-11-08 13:16:17

标签: python dice

需要询问用户是否要开始,最终得到最多1个参数的预期输入,得到3:

for i in range(1,5):
    Player1Points += roll()
    print('After this round ',player_1, 'you now have: ',Player1Points,' Points')
    while True:
        answer = input("Would you like to see", player_2, "'s score? yes/no")
        if answer == "no":
            print("how about now?")
        else:
            print("Okay")
        break

Player2Points += roll()
print('After this round ',player_2, 'you now have: ',Player2Points,' Points')

预计最多输入1个参数,但得到3个。

1 个答案:

答案 0 :(得分:4)

您需要连接字符串,不要像打印功能那样使用逗号。使用

answer = input("Would you like to see" + player_2 + "'s score? yes/no")

相反。或者,如果您使用的是python 3.5 +

answer = input(f"Would you like to see {player_2}'s score? yes/no")