Slicing allows you to extract a portion (substring) of a string using a specific syntax.
text = "Artificial Intelligence is changing the world."
slice_result = text[2:5]
print("Original Text:", text)
print("Sliced Text [2:5]:", slice_result)
Do it
Slice from Beginning
In Python, you can slice a string from the beginning up to (but not including) any index 5 (example)using the syntax text[:5].
text = "Programming is fun!"
slice_result = text[:5]
print("Original Text:", text)
print("Sliced Text [:5]:", slice_result)