+ 3
Can anyone tell me, how to solve this problem?
Var="I love python" Print(var[2:6]) Output : Love How to read (2:6)?
5 Answers
+ 6
Var[0] = i, var[1]=' ', var[2]=l, var[3]= o..
+ 2
Randomocity Thank you! Now, I understand
+ 2
Julia Shabanova thanks! âș
0
var="I love python"
print(var[2:6])
0
what your using is called list slices. the only show a slice of the list. they work in this style [start:stop:step].
start is the index of the list you start, in this case 2. stop is the index you end, here 6. and the step is rate at which it loops though, defaults to 1. a step of 2 mean every 2nd value in-between the start and stop.
https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2453/