Tech C**P
15 subscribers
161 photos
9 videos
59 files
304 links
مدرس و برنامه نویس پایتون و لینوکس @alirezastack
Download Telegram
How to reverse a string in python?

By slicing it is easy as pie! The general format of string slicing is like below:

'YOUR_STRING'[begin : end : step]

We do a little bit of a magic here and make step -1. -1 will read data from the end of the string to the first character and leave begin and end intact:

'Hello'[::-1]

The output would be like below:

>>> 'hello'[::-1]
'olleh'

#python #string #slicing #step #reverse