为什么每次尝试运行时都会在第一个打印行上出现语法错误?
def dice():
import random
diceAmount = input('How many dice (Up to 5)')
diceNumbers = [1,2,3,4,5,6]
if diceAmount > 1:
die = "die"
else:
die = "dice"
diceTotal = (math.factorial(6)/((math.factorial(6-
random.choice(diceNumbers))*math.factorial(random.choice(diceNumbers)))
print("You chose " +diceAmount + die)
print(diceTotal*diceAmount)
dice()
答案 0 :(得分:0)
这是固定代码
def dice():
import random
import math
diceAmount = input('How many dice (Up to 5)')
diceNumbers = [1,2,3,4,5,6]
if diceAmount > 1:
die = "die"
else:
die = "dice"
diceTotal = math.factorial(6)/math.factorial(6-random.choice(diceNumbers))*math.factorial(random.choice(diceNumbers))
print "You chose " +diceAmount + die
print diceTotal*diceAmount
dice()