0

String

Let s be an string then what s[5:] and s[:5] means?

2nd Jun 2020, 4:32 PM
Shivam
4 odpowiedzi
+ 1
s[5:] is similar to s[5:len(s)] Basically it prints values from index 5 till the end of the list or string. s[:5] is similar to s[0:5] It prints values from index 0 till 4. Index 5 is excluded.
2nd Jun 2020, 4:39 PM
Avinesh
Avinesh - avatar
+ 1
Yes when you start from the end, the last element is at index -1.
2nd Jun 2020, 5:57 PM
Avinesh
Avinesh - avatar