Home Coding Data Structure – Lists 03

Data Structure – Lists 03

0
Data Structure – Lists 03

# Lists methods and function
# We will see some of the most used method and function for lists
# We will see: 
# sort(), append(), len(list), count(), insert(), pop(), 
# index(), remove(), reverse(), extend(), max(list),
# min(list), clear(), copy(), type(list)
#
# INSERT -  COUNT - INDEX

# I'm a list. 
list1 = ["Apple", "Banana", "Kiwi"]

#The insert() method inserts the required value at
# the desired position.
# what if we want to insert a couple of items between
# the Apple and Banana
list1.insert(1,"Orange")
list1.insert(1,"Orange")

# How many Orange are in list1?
oranges = list1.count("Orange")

# What if I want to see where is the first Apple?
apple = list1.index("Apple") 

# copy www.AEC.codes
OUT = (list1, oranges, apple)