Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- myList = ["Tom", "Jim", "Jackie", "John"]
- print(myList)
- time.sleep(2)
- print("Appending Jenny to end of list")
- myList.append("Jenny")
- print(myList)
- time.sleep(2)
- print("Inserting 23 into list")
- myList.insert(2,23)
- print(myList)
- time.sleep(2)
- print("Adding another list to myList")
- myList.extend(["Alan", "Jenny"])
- print(myList)
- time.sleep(2)
- print("Removing the first item from list")
- myList.pop(0)
- print(myList)
- time.sleep(2)
- print("Remove first time Jenny appears")
- myList.remove("Jenny")
- print(myList)
- time.sleep(2)
- print("Clear the whole list")
- myList.clear()
- print(myList)
- time.sleep(2)
- print("New list set up")
- myList = ["Tom", "Jim", "Jackie", "John", "Alan", "Jenny", "Sandra"]
- print(myList)
- time.sleep(2)
- print("Slice the list [1:4]")
- print(myList[1:4])
- time.sleep(2)
- myList2 = [[1,2,3],[4,5,6],[7,8,9],[10,11,12]]
- print("myList2 = " + str(myList2))
- time.sleep(2)
- myList2[2].append(7)
- print("Append 7 to the third list")
- print(myList2)
- time.sleep(2)
- print("Add a new list with myList2")
- myList2.append([10,12,13])
- print(myList2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement