0

我正在尝试编写代码来执行此操作:

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?"))

有没有人有任何解决方案我可以解决这个问题?

4

1 回答 1

1

我不明白你的问题是什么。help(n) 的代码是正确的。

您只需要检查输入,然后运行您的函数帮助:

print "how many SOS! do you want to call? "
int n = input()
print n
help(n).
于 2013-11-06T15:43:55.693 回答