Python Lists

•

Disscuss about how the lists were made and updates their items using append and remove function

What is list..

list is nothing but bunch of different items that are placed in a single unit..

let’s see how does the lists were made and do some operations on it..

How to declare a list is written below

data = ['flowers','cars','admin']

now check type of ” data ” is it list or tuple using type() function this is only for your confirmation dont add below line to your code its extraa..

now it’s time to do some operations on list

how to add a new item to list

# this line add new item to your list
data.append(planets)

now print the list again to check whether it’s updated or not…

print("Updated List: ",data)

now see how to remove a item from list using remove function

# this will remove the cars from your list
data.remove(cars) 

if you don’t do any mistake you’ll see the list is updated…

want to download this code go to ” working with codes ” sectionn code will uploaded there soon…

Leave a Reply

Your email address will not be published. Required fields are marked *