Mutable classification – List , Dict, Sets

  • Value of Mutable data types can be changed post creation.
  • MUD operations can be performed on Mutable objects
  • Mutable Object iterations can be coupled with MUD

List

values = [4, 5, 6]
values = [4, 5, 6]

values2 = values

print(id(values))
print(id(values2))

Values[0]=8

print(values)   #[8, 5, 6]
print(values2)  #[8, 5, 6]

Output :

Id-2450343166664

Id-2450343166664

Tuple with List

skills = ["Programming", "Machine Learning", "Statistics"]

person = (129392130, skills)
print(type(person))

print(person)
skills[2] = "Maths"
print(person)

Points to Remember

  • Mutable objects are cheap as can be altered easily

0 Comments

Leave a Reply

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