E-mail : support@tech2now.in

String Slice program in Python

We can use: for string slicing, examples are below


str = 'Learn python and enjoy Programming'
str_1 = str[3::]
print (str_1)

str_2 = str[3:15:]
print (str_2)

str_3 = str[3:15:3]
print (str_3)

str_4 = str[::4]
print (str_4)
Ouput:
rn python and enjoy Programming
rn python an
rph
Lnt  oran   

GitHub Repository URL (Source code)