題目:利用遞歸函數調用方式,將所輸入的5個字符,以相反順序打印出來。
練習代碼:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
def output(s):
if s=='':
return
print(s[len(s)-1:len(s)])
output(s[:len(s)-1])
s=input('請輸入字符:')
output(s)
題目:利用遞歸函數調用方式,將所輸入的5個字符,以相反順序打印出來。
練習代碼:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
def output(s):
if s=='':
return
print(s[len(s)-1:len(s)])
output(s[:len(s)-1])
s=input('請輸入字符:')
output(s)
繼續運行 ?* 回憶上次內容 上次使用shell環境中的命令 命令 作用 c