Python - Slicing Strings code example
Example 1: python slice string
name = "dx4iot"
print(name[0:]) #output: dx4iot
print(name[0:3]) #output: dx4
#==== reverse a string ====#
print(name[::-1]) #output: toi4xd
print(name[0:6:2]) #output: d4o
print(name[-4:-1]) #output: 4io
Example 2: string slicing in python 3 arguments
#[start:end:step]
>>> range(10)[::2]
[0, 2, 4, 6, 8]
Example 3: how to slice a string in python
a = 'hello'
print(a[1:2])
Example 4: Python - Slicing Strings
b = "Hello, World!"
print(b[2:5])