我希望能够使用函数和 while 循环打印代表数字的符号
前任:
number = 250
# symbols
C = 100
^ = 50
应该打印
CC^
虽然打印一个函数可能有效,但尝试连接两个或多个打印函数会导致我出现类型错误:
TypeError: can't multiply sequence by non-int of type 'function'
number = 251;
def numeral_C(number_par):
while number_par >=100:
numeral_C = number_par / 100
print "C"*numeral_C,
number_par = number_par - numeral_C*100
return ""
def numeral_UpArrow(number_par):
while number_par >=50:
numeral_upArrow = number_par / 50
print "^"*numeral_UpArrow, #error
number_par = number_par - numeral_UpArrow*50
return ""
etruscan_C = str(numeral_C(number))
etruscan_UpArrow = str(numeral_UpArrow(number)) #error
print etruscan_C+etruscan_UpArrow
Traceback (most recent call last):
File "/Applications/Wing IDE/WingIDE.app/Contents/MacOS/src/debug/tserver/_sandbox.py", line 15, in
File "/Applications/Wing IDE/WingIDE.app/Contents/MacOS/src/debug/tserver/_sandbox.py", line 11, in numeral_UpArrow
**TypeError: can't multiply sequence by non-int of type 'function'
我想知道,有没有一种方法可以打印两个或多个函数而不会出现错误?