Pythonは演習27を含んでいます
タイトル:再帰関数呼び出しは、5文字は逆の順序でプリントアウト、入力されています。
プログラム解析:なし。
ソースコード:
#!/usr/bin/python # -*- coding: UTF-8 -*- def output(s,l): if l==0: return print (s[l-1]) output(s,l-1) s = raw_input('Input a string:') l = len(s) output(s,l)
上の例の出力は、次のとおりです。
Input a string:abcde e d c b a