List and tuple in Python

Jakubowski Sr.

New member
Joined
Aug 3, 2024
Messages
2
Points
1
I've used python for a while, and I don't think I ever thought about this question! lol

I think a list is for storing one data type of variables, like all int's. A tuple would be used if you wanted to store an int, and string in the same object list.
 

Dr. Hank

New member
Joined
Aug 3, 2024
Messages
2
Points
1
Use a list when you need a collection of items that can be modified (mutable). Lists are suitable for situations where you may add, remove, or modify elements.
Use a tuple when you need an immutable collection of items.
 
Top