Write a Python program to append a list to the second list.
Answers
Answered by
2
Answer:
append() and extend() in Python
If you append another list onto a list, the parameter list will be a single object at the end of the list. extend(): Iterates over its argument and adding each element to the list and extending the list. The length of the list increases by number of elements in it's argument
Explanation:
Answered by
4
list_1 = eval(input("Enter a list: "))
list_2 = eval(input("Enter a second list: "))
nl = list_2.append(list_1)
print(nl)
The append() list function enables users to add a list to another list of elements.
This is similar to the extend() function.
Other list functions:
- remove() - removes the specified element from the list.
- sum() - adds all the elements in the list, provided they're numbers.
- copy() - creates a copy of the list.
- sort() - arranges the list in order.
- sorted() - arranges the list in order temporarily.
- pop() - removes the element from the specified index position.
Similar questions