Let’s say you want to revers the content of a string in Python. For example instead of “Dan” you want to be displayed “naD” (in reverse).
You can do it by using slice notation. You select all of the individual characters but in reverse order.
>>> s1 = 'Dan' >>> s2 = s1[::-1] >>> s2 'naD'