码迷,mamicode.com
首页 > 编程语言 > 详细

python3练习100题——027

时间:2018-06-15 12:51:04      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:www   www.   htm   example   int   lease   ISE   fun   NPU   

又是一道迭代的题,没做好。

看了答案才试着写出来。 我一定要加油啊,为了尽快摆脱现在讨厌的生活!

原题链接:http://www.runoob.com/python/python-exercise-example27.html

题目:利用递归函数调用方式,将所输入的5个字符,以相反顺序打印出来。

我的代码:

a = input("please input a string:")

def fun(s,l):
    if l==0:
        return
    else:
        print (s[l-1])
        fun(s,l-1)        #再调用一遍函数,用于迭代!

fun(a,len(a))

 

python3练习100题——027

标签:www   www.   htm   example   int   lease   ISE   fun   NPU   

原文地址:https://www.cnblogs.com/drifter/p/9186170.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!