Reverse a string in Python

前端 未结 28 3334
南旧
南旧 2020-11-21 04:41

There is no built in reverse function for Python\'s str object. What is the best way of implementing this method?

If supplying a very conci

28条回答
  •  生来不讨喜
    2020-11-21 04:49

    original = "string"
    
    rev_index = original[::-1]
    rev_func = list(reversed(list(original))) #nsfw
    
    print(original)
    print(rev_index)
    print(''.join(rev_func))
    

提交回复
热议问题