需要了解解决方案 [英] Need to understand about a solution
本文介绍了需要了解解决方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
def reverse(文字):
word =
l = len(文字) - 1
而l> = 0 :
word = word + text [l]
l - = 1
返回单词
请帮我理解这个解决方案。什么&它是如何制作的?
我尝试了什么:
def反向(文字):
word =
l = len(文字) - 1
而l> = 0:>
word = word + text [l]
l - = 1
返回单词
def reverse(text):
word = ""
l = len(text) - 1
while l >= 0:
word = word + text[l]
l -= 1
return word
please help me to understand about this solution. what & how it was made?
What I have tried:
def reverse(text):
word = ""
l = len(text) - 1
while l >= 0:
word = word + text[l]
l -= 1
return word
推荐答案
这很明显:它所做的只是查找字符串的长度,然后将每个字符附加到从右端开始并且工作到开头的单词。
拿一张纸和一支铅笔,然后亲自按照说明操作 - 你很快就会看到它是如何工作的。
It's pretty obvious: all it does is find out the length of the string, then append each character to the word starting from that the right end and working to the beginning.
Get a piece of paper and a pencil, and try following the instructions yourself - you'll soon see how it works.
这篇关于需要了解解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文