a = '1234'
print a[3:0:-1]
Output: 432
In slicing we know that list[start:stop:step] In the output how come '32' comes. I believe -1 gives len(list)-1 but if that is the case then how come its '32' Your suggestions will be helpful thanks
a = '1234'
print a[3:0:-1]
Output: 432
In slicing we know that list[start:stop:step] In the output how come '32' comes. I believe -1 gives len(list)-1 but if that is the case then how come its '32' Your suggestions will be helpful thanks
the trick here is -1
a = '1234'
print a[3:0:-1]
the following code mean start from a[3] = 4 and decrease -1 until you arrive to a[0] = 1 but don't print a[0]