Difference Between List and Tuple in Python

Master Python with 70+ Hands-on Projects and Get Job-ready - Learn Python

Program 1

import sys
mylist=[100,"Hello",True,12.44,15+5j,"Bhopal",100,500,100]  # Mutable

# print(mylist)
# mylist.append("Bye Bye")
# print(mylist)

mytuple=(100,"Hello",True,12.44,15+5j,"Bhopal") # Immutable


# print("Size of List",sys.getsizeof(mylist))
# print("Size of Tuple",sys.getsizeof(mytuple))


#mytuple[1]="Indore City"
# print(mylist)
# mylist[1]="Indore City"
# print(mylist)
#print(type(mylist))
#print(type(mytuple))

 

Did we exceed your expectations?
If Yes, share your valuable feedback on Google

courses

DataFlair Team

DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.

Leave a Reply

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