Computer (2nd Quarter) Flashcards
Making a list called “list” with the items: “Item1”, “Item2”, and “Item3”
list = [“Item1”, “Item2”, “Item3”];
List items are indexed, the first item has index:
0
Make the result “green”
colorlist = [ “red”, “blue”, “green”]
print(colorlist [ 2 ])
Adds an element at the end of the list
append( )
Adds an element at the specified position
insert( )
Removes the item with the specified value
remove( )
Removes all the elements from the list
clear( )
Add “black” to the end of the list “colorlist”
colorlist.append(“black”)
Add “white” to the beginning of the list “colorlist”
colorlist.insert(0, “white”)
Remove “blue” from the list “colorlist”
colorlist.remove(“blue”)
Clear the “colorlist”
colorlist.clear( )
Remove the element at the third position from the list “colorlist”
colorlist.pop(3)
Print “colorlist”
print(colorlist);
Add the elements of a list, to the end of the current list
extend( )
Extend “colorlist” by adding the list “numberlist”
colorlist.extend(numberlist)