我正在尝试制作代码来执行此操作:
how many 'SOS!' do you want to call? 5
SOS!SOS!SOS!SOS!SOS!
但我能想到的就是这个
print "please tell me how bad your situation is, how many SOS! do you want to call?"
def help(n):
if n <= 0:
print "Don't SOS! if you don't need help!"
elif n > 1:
print "SOS!"
help(n-1)
else:
print "SOS!"
help(input("how many SOS! do you need to call?"))
有没有人能解决这个问题?
答案 0 :(得分:1)
我不明白你的问题是什么。 help(n)的代码是正确的。
您只需要检查输入,然后运行功能帮助:
print "how many SOS! do you want to call? "
int n = input()
print n
help(n).