Get the App
SLTechnology News&Howtos  ›  Development  › 

How to reverse string or sequence by python

Shulou Source: shulou.com Published: 2022-06-01 04:23:48 10月04日 Update

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!

Tags: Reverse order characters strings series articles content not much most ways methods more for knowledge industry information information channels channels references learning help Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Linux Xiaomi Docker OPPO Reno