+ 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)?

9th Aug 2020, 9:12 PM
Givantaro Coding
Givantaro Coding - avatar
5 odpowiedzi
+ 6
Var[0] = i, var[1]=' ', var[2]=l, var[3]= o..
9th Aug 2020, 9:27 PM
Julia Shabanova
Julia Shabanova - avatar
+ 2
Randomocity Thank you! Now, I understand
9th Aug 2020, 11:47 PM
Givantaro Coding
Givantaro Coding - avatar
+ 2
Julia Shabanova thanks! ☺
9th Aug 2020, 11:47 PM
Givantaro Coding
Givantaro Coding - avatar
0
var="I love python" print(var[2:6])
9th Aug 2020, 9:14 PM
Punyasloka Mahapatra
Punyasloka Mahapatra - avatar
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/
9th Aug 2020, 10:34 PM
Randomocity
Randomocity - avatar