Alternate Python List Reverse Solution Needed

后端 未结 7 647
清酒与你
清酒与你 2021-01-22 09:54

I had a job interview today. During it I was asked to write down an algorithm that will reverse a list. First I offered the answer using the reversed() method:

          


        
7条回答
  •  醉话见心
    2021-01-22 10:42

    def reverse(text):
      rev = []
      for let in range(len(text),0,-1):
        rev.append(text[let-1])
      return ''.join(rev)
    

提交回复
热议问题