+ 4
example="snow world". print("%s" % example[4:7])
please any one explain
2 Respostas
+ 2
[4:7] is referred to the index
s n o w " " w o r l d
0 1 2 3 4 5 6 7 89
so [4:7] means from index 4 to 7 so
" wo" because it incude the first one but exclude the last one
You can also use it with negatives index like [5:-1] that means from character 5 to the last one.(world)
The third "parameter" is [3:8:2]
that means that only take one charachter each 2 like wwr. if megative reverse the string
0
Hsis