Given a string, write a Python program to get the substring from given string using list slicing. Let’s try to get this using different examples.
In this example, we will see how to take a substring from the end or from starting of string.
initial_strings : xbzefdgstb print resultant substring from start xb print resultant substring from end efdgstb
In this example, we will see how to create a string by taking characters from the certain positional gap.
initial_strings : xbzefdgstb print resultant substring from start xzfgt print resultant substring from end xegb
In this example, we are considering both cases of taking string from the middle with some positional gap between characters.
initial_strings : xbzefdgstb print resultant substring zfg
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course