May-31-2020, 06:15 AM
(May-30-2020, 09:30 PM)divyansh Wrote: str1="divyansh tiwari" # this is just a string
var1=str1[-1:-16:1] # in this i know that the slicing will start at -1 index that is the last index and will end on the -16th index that is excluding -16th index but here i used a positive number for steps that is 1 and this kinda slicing is making my control to go beyond the indexes but it is not show a error i am fine with that but its also not showing any output i am fine with that too but lets look down to the var2
print(var1)
var2=str1[-1:16:1] # here same terminology is used but the stopping index in changed to +16 from -16 and this is showing me a output that is prompting me with the last "i" in the string str1
print(var2)
# my question is that why second one is showing a output ( if you say that slicing includes the start index then what happened with the var1 output it is also starting with the same index)
Please, post your code - you should have a first go at it - and also, use proper code tags not pictures, unless code is too big
pyzyx3qwerty
"The greatest glory in living lies not in never falling, but in rising every time we fall." - Nelson Mandela
Need help on the forum? Visit help @ python forum
For learning more and more about python, visit Python docs
"The greatest glory in living lies not in never falling, but in rising every time we fall." - Nelson Mandela
Need help on the forum? Visit help @ python forum
For learning more and more about python, visit Python docs