
30 cool Python tricks including Slicing, In-place Swap, List vs. Tuple etc
30 cool Python tricks including Slicing, In-place Swap, List vs. Tuple etc
1. Slicing
Access or reverse sequences using sequence[start:stop:step]
.
a = "Hello World!"
print(a[::-1]) # !dlroW olleH