How to reverse string or sequence by python
Editor to share with you python how to achieve string or sequence reverse order, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
String / sequence reverse order
You can quickly reverse the sequence in the following ways:
> a = [1 This creates a new reversed list 2, 3 4] > a [::-1] [4, 3, 2, 1] # pas. # If you want to reverse a list in place you can do:a.reverse ()
This general approach also applies to the reverse order of strings:
> foo = "yasoob" > > foo [::-1] 'boosay' is all the contents of this article "how to reverse strings or sequences in python". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!