Python  reverse

define a function called reverse that takes a string text and return that string in reverse.
You may get a string containing special characters(for example,!,@,or #).

def reverse(text)
char = len(text) - 1
st = ""
while char >= 0:
st += text[char]
char -= 1
return st

def reverse(text):
st =""
while len(text)>0:
char = text[len(text)-1]
st += char
char -= 1
return st

return 前面也可以加else
else:
return st
while 前面也可以加个for 循环
for x in text:
while

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容