0

a= "hello" #tab print(a[0:5:2]) what is purposes of 2

....

29th Feb 2020, 1:59 AM
Bishnu Chalise
Bishnu Chalise - avatar
2 Antworten
+ 5
"...List slices can also have a third number, representing the step, to include only alternate values in the slice..." https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2453/?ref=app
29th Feb 2020, 2:10 AM
Hatsy Rei
Hatsy Rei - avatar
+ 3
It's like the step amount it takes. So since it's 2 it'll print every other character in the string starting at index 0 ending at index 5 . Index 0 = H Index 2 = l Index 4 = o
29th Feb 2020, 2:09 AM
Austin