+ 4

example="snow world". print("%s" % example[4:7])

please any one explain

4th Sep 2018, 6:23 AM
‏‪‏‪Sammy_Jamez‬‏‬‏
‏‪‏‪Sammy_Jamez‬‏‬‏ - avatar
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
4th Sep 2018, 6:49 AM
Daniele Bonomi
Daniele Bonomi - avatar
0
Hsis
16th Jan 2023, 5:19 AM
Abhishek Rai
Abhishek Rai - avatar