Changing , Adding and Removing Elements 

Run Settings
LanguagePython
Language Version
Run Command
# Changing Elements # MODIFTYING ELEMENTS IN A LIST Number = ['1','2','3','4','5','6','7','8'] Number[3] = '33' print(Number) # Exercise Write a Story about Buying and I want to replace Something Shopping_list = ['Fruits','Soda','Water','Chips'] Shopping_list[3] = 'Coffee' print(Shopping_list) # NOW BY CHANGING A RANGE OF ITEMS VALUES Shopping_list[2:3] = ["Coffee","Tea"] # Range of items print(Shopping_list) # If you insert more items than you replace Foods = ['Pizza','Chips','Burger'] Foods[:1] = ['Wings','Chicken fries'] #Note: The length of the list will change when the number of items inserted does not match the number of items replaced. print(Foods) # if you insert more less items what will happened? Foods[1:4] = ['Sausage'] # Note: Change the second and third value by replacing it with one value print(Foods) # Adding List Items # Append Items # Example Phone_Accessories = ['Samsung','IPhone','Huawei'] Phone_Accessories.append('HTC') print(Phone_Accessories) # Insert Item # NB To add items at a Specific Position in a List Phone_Accessories.insert(1,'Nokia') # we are using example on Phone_Accessories print(Phone_Accessories) # REMOVING ELEMENTS FROM A LIST # The following Elements froma a list using The Following Methods # remove() Cars = ['Bugattes','Rolls Royce','Mercendes Benz','Maclaren'] Cars.remove('Rolls Royce') # we have used on remove() method on it means removing on the item from the list print(Cars) # Another Example Kichen_Accessories = ['Pie','Pizza','Rice'] Kichen_Accessories.remove('Pie') print(Kichen_Accessories) # pop() # Another one is maybe tricky but is understandable Vehicles = ['Bmw','Mercedes Benz','Volkswagon','G-wagon Benz'] Michael_Vehicles = Vehicles.pop(3) print('Within all ', Vehicles , ' I want ' + Michael_Vehicles + '.') # What does it means It's means that I created two Value item and the Value of pop i imported on the Value item So i decided to make as a story. # del # This is also removes on specified Index
Editor Settings
Theme
Key bindings
Full width
Lines