How to append only the x first elements of a list, to another list. | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 2

How to append only the x first elements of a list, to another list.

Append the x first elements

26th Apr 2018, 9:08 PM
Hakim
Hakim - avatar
1 ответ
+ 7
list1= [1,2,3,4,5] list2=[5,4] list2+=list1[:4] print(list2) output: 5,4,1,2,3,4
26th Apr 2018, 9:27 PM
Tomer Sim
Tomer Sim - avatar