Answers for "python get first and last element of list and add to a new list"

3

how to insert item last in list python

list = [item, item1, item2...]
list.insert(len(list), other_item)
#For results just print the list, it should work...
#Also courtesy of Stack Overflow
Posted by: Guest on April-08-2020
2

python list add first

# list.insert(before, value)
list = ["a", "b"]
list.insert(0, "c")
print(list)     # ['c', 'a', 'b']
Posted by: Guest on May-13-2021

Code answers related to "python get first and last element of list and add to a new list"

Python Answers by Framework

Browse Popular Code Answers by Language