Q. What is a string slice? How is it useful?


Answer =

A sub-part or a slice of a string, say s, can be obtained using s [n: m] where n and m are integers.

Python returns all the characters at indices n, n+1, n + 2 ... m - 1

For example :-
>>> 'Path Walla' [1:4]
>>> 'ath'

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post