我有这段代码,但是每当我输入任何数字奇数甚至是偶数时(缩进在这里可能都不正确,但这并不是程序中的原因)...
import random
number1 = random.randint(1,6)
number2 = random.randint(1,6)
input("Ready for round one? Press enter key to begin!")
print("Player one, you rolled", number1, "and", number2)
number3 = number1 + number2
time.sleep(1)
print("This means your total is", number3)
time.sleep(1)
if number3 == ("1", "3", "5", "7", "9", "11"):
print("However, you rolled an odd. -5 points for you!")
p1score = number3 -5
else:
print("Also.... YOU GOT AN EVEN! +10 Points!")
p1score = number3 +10
time.sleep(1)
print("Player ones total is", p1score)
答案 0 :(得分:1)
if number3 % 2 != 0:
print("However, you rolled an odd. -5 points for you!")
p1score = number3 - 5
以此替换您的奇怪逻辑