+ 3

What's the difference between a set, a list and a tuple?

I don't seem to wrap my head around it any practice suggestion codes?

14th May 2022, 12:53 PM
Olinymous
Olinymous - avatar
2 Answers
+ 5
set : don't allow dublicate values. created by curly braces { } or by set() function s = { 1,2,3,4 } or set(1, 2,3,4) array : a list of values, a list of lists. created by squire brackets [ ] or list() function l = [ 1,2, 3, 4 ] , l = list(1, 2, 3, 4) tuples : same as list but immutable means ones created, can't be changed.. created by paranthesis ( ) or by tuple() function t = (1, 2, 3, 4) or tuple(1, 2, 3, 4)
14th May 2022, 12:59 PM
Jayakrishna 🇼🇳
+ 4
Sets are also unordered so none of the items are indexed If you want to practice make a list with some values including duplicates. Play around with some list methods (see W3schools if you want) You can then covert your list to a set by doing set() around your list or use tuple() for tuple type and play around with methods and manipulating the data see what happens
14th May 2022, 1:00 PM
Amaani
Amaani - avatar