+ 1

How it works?

dont understand why i can add 'str' but cant 'int'. https://code.sololearn.com/csjsCNefgCY0/?ref=app

20th Apr 2018, 7:16 PM
andrey
andrey - avatar
3 Respuestas
+ 5
or n[1:1] = "1" list and strings are iterable. 1 is an integer an not iterable. The types of the items in the list of the left side dont matter.
20th Apr 2018, 8:03 PM
Oma Falk
Oma Falk - avatar
+ 2
It not depends on int... For append slice you must use a Iterable object (and string its)... Try with: n[1:1]= [1] Here you use a list (thats an iterable object) when you cant get errors
20th Apr 2018, 7:57 PM
KrOW
KrOW - avatar
+ 1
i forgot about iterable.. for 'append' ))) thanks
20th Apr 2018, 8:05 PM
andrey
andrey - avatar