Python Dodaj do listy z indeksem
list.insert(index, element)
Woolly Necked Stork
list.insert(index, element)
myList = [apples, grapes]
fruit = input()#this takes user input on what they want to add to the list
myList.append(fruit)
#myList is now [apples, grapes, and whatever the user put for their input]
fruits = ["Apple", "Banana"]
# 1. append()
print(f'Current Fruits List {fruits}')
f = input("Please enter a fruit name:\n")
fruits.append(f)
print(f'Updated Fruits List {fruits}')
a=[1,2,3]
b=[2,3,4]
a.append(b)
# Statically defined list
my_list = [2, 5, 6]
# Appending using slice assignment
my_list[len(my_list):] = [5] # [2, 5, 6, 5]
# Appending using append()
my_list.append(9) # [2, 5, 6, 5, 9]
# Appending using extend()
my_list.extend([-4]) # [2, 5, 6, 5, 9, -4]
# Appending using insert()
my_list.insert(len(my_list), 3) # [2, 5, 6, 5, 9, -4, 3]