I am new in Python 3. Today while reading about python reverse string using list I came to know an in-place slicing technique. The code looks like this:
s = input("Enter a string:\n")
''.join([ s[x:x+2][::-1] for x in range(0, len(s), 2) ])
I want to know how applying second in-place slice s[x:x+2][::-1]
working for the pairwise character swap? For other languages, using [something] [something]
denotes 2D array interpretation. How this is reversing the sliced pair?
Can you please explain? Thanks in advance.