我正在运行:
def add (a, b):
print "ADDING %d + %d" % (a, b)
return a + b
def subtract (a, b):
print "SUBSTRACTING %d - %d" %(a, b)
return a -b
def multiply (a, b):
print "MULTIPLYING %d * %d" % (a, b)
return a * b
def devide (a, b):
print "DEVIDING %d / %d" % (a, b)
return a / b
print " lets do some math with just function!"
age = add(30, 5)
hight = subtract (78, 4)
weight = multiply (90, 2)
iq = divide = (100, 2)
print "Age: %d, Hight: %d, Weight: %d, IQ: %d" % (age, hight, weight, iq)
我得到了这个:
TypeError: %d format: a number is required, not tuple
但为什么?
答案 0 :(得分:2)
您的代码中只有一些错字:
iq = divide = (100, 2)
def devide (a, b):
需要成为
iq = divide(100, 2)
def divide (a, b):