Can i change list index from 0 to 1? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Can i change list index from 0 to 1?

20th May 2018, 6:07 PM
PUNNA RAJASHEKAR
PUNNA RAJASHEKAR - avatar
8 Answers
+ 1
why would you need to do that?
20th May 2018, 6:12 PM
Bebida Roja
Bebida Roja - avatar
+ 1
I want to print 2 consecutive indexes by escaping third index. For that I wrote some logic but it works if index starts from 0.
20th May 2018, 6:15 PM
PUNNA RAJASHEKAR
PUNNA RAJASHEKAR - avatar
+ 1
just add one where you use the index
20th May 2018, 6:17 PM
Bebida Roja
Bebida Roja - avatar
+ 1
Well, yes, in a way, you could add an element called zero that you would skip and then continue looping from the second element onwards, if you mean you want to switch the index, then it all depends on the data structure, if it is something like a list there shouls be a get function, if it is an array the [index] will get you the element at that index.
20th May 2018, 6:17 PM
Idriz Pelaj
+ 1
Yes, it works. I am also wrote in same way
21st May 2018, 1:28 AM
PUNNA RAJASHEKAR
PUNNA RAJASHEKAR - avatar
0
But the problem with index, it skips 0 index if i did like this
21st May 2018, 1:35 AM
PUNNA RAJASHEKAR
PUNNA RAJASHEKAR - avatar
0
Anyway i got the answer from bebida Roja. I need to add 1 duplicate element in 0 index.
21st May 2018, 1:36 AM
PUNNA RAJASHEKAR
PUNNA RAJASHEKAR - avatar
0
Thank you everyone
21st May 2018, 2:25 AM
PUNNA RAJASHEKAR
PUNNA RAJASHEKAR - avatar