+ 2

explain negative indexing [1::-3],[1::-2],[1::-5],

What is the output of this code? S= "Welcome" print(s[2::-4])

12th Feb 2023, 7:28 AM
Gaurav Ghadge
Gaurav Ghadge - avatar
7 Respuestas
+ 3
You could yourself test and play with this code in SL playground. In this way you can better understand how that works.
12th Feb 2023, 7:46 AM
JaScript
JaScript - avatar
+ 1
now get
12th Feb 2023, 8:07 AM
Gaurav Ghadge
Gaurav Ghadge - avatar
+ 1
Thanks everyone
12th Feb 2023, 8:15 AM
Gaurav Ghadge
Gaurav Ghadge - avatar
0
 the index value of -1 gives the last element, and -2 gives the second last element of an array. The negative indexing starts from where the array ends. This means that the last element of the array is the first element in the negative indexing which is -1.
12th Feb 2023, 7:58 AM
Herobrine
Herobrine - avatar
0
Please Correct Me if iam wrong
12th Feb 2023, 8:00 AM
Herobrine
Herobrine - avatar
0
yes you are correct but -4 means you can count form last number to forth
12th Feb 2023, 8:02 AM
Gaurav Ghadge
Gaurav Ghadge - avatar
0
I didn't get
12th Feb 2023, 8:02 AM
Gaurav Ghadge
Gaurav Ghadge - avatar