Python 练习实例27
2022-04-03 本文已影响0人
loinue
来自菜鸟教程
https://www.runoob.com/python/python-exercise-example27.html
题目:利用递归函数调用方式,将所输入的5个字符,以相反顺序打印出来。
程序分析:无。
程序源代码:
实例(Python 3.0+)
#!/usr/bin/python3
def output(s,l):
if l==0:
return
print (s[l-1])
output(s,l-1)
s = input('Input a string:')
l = len(s)
output(s,l)
以上实例输出结果为:
Input a string:abcde
e
d
c
b
a
还没起床,还是有点困,是因为休息没动力么。不,不可以!