+ 1
Listbox in Python
I have read online that " insert(index,*elements) will insert one or more new lines into the listbox before the line specified by index ". I am getting the correct order in my code1(Listbox1) but not correct order in code2(Listbox2). https://code.sololearn.com/cXvqPc0HcE7b/?ref=app https://code.sololearn.com/cpV5ks7OehTT/?ref=app
4 Réponses
+ 3
If you try to insert an element at index 4 of an empty list, it will be appended as the last (=first) element since there is no index 4. The next element that you try to insert at index 3 will be appended at the end since there is still no index 3. Only when there are enough elements in your list it will start to insert new elements at the given indices
+ 3
harshit Actually it's exactly like I'm saying. Long story short, if you want your list to be sorted in a useful way, don't insert elements at indices that don't exist
https://code.sololearn.com/cWXcb5qxuuo6/?ref=app
https://code.sololearn.com/chJAAVJ3AgdI/?ref=app
+ 1
Diego please see this.