What is the slice from index 1


#1

i don't know what the slice from index 1 is.


#2

Hi, @netsolver77346 ,

If you had a variable, my_word, for example, representing a string, and you wanted to assign it the slice from itself, beginning at index 1, you could do this ...

my_word = my_word[1:]

The new string assigned to my_word would contain everything from the original string, except for the first character, which had an index of 0.


#3

if the string is hello then it will be stored as :slight_smile:
[h][e][l][l][o]
where,
[h]=is the zeroth index
[e]=is the first index
[l]=is the second index
[l]=is the third index
[o]=is the fourth index
so, slicing will be from first index to the last index


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.