In python sequences are of 3 types i.e list,tuples, dictionaries.But in some websites iam finding sets as well. Is it true?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

In python sequences are of 3 types i.e list,tuples, dictionaries.But in some websites iam finding sets as well. Is it true??

7th Jul 2020, 2:34 PM
Sufia Hashmi
Sufia Hashmi - avatar
2 Answers
+ 1
In python, those lists, tuples, dictionaries are data structures - "some ways to represent basic data". In addition to these sets are also a data structure, in contrast, that does not allow dublicate values. Where as list, tuples, allows dublicates.
7th Jul 2020, 3:17 PM
Jayakrishna 🇮🇳
0
A sequence has to have an order. Sets and dictionaries are not ordered, so they wouldn't count as sequences in the strict sense. I'm wondering, though... since dicts now remember the order in which stuff was entered, are they hybrids now? I'd only consider lists, tuples, strings, bytestrings and such types as sequences.
7th Jul 2020, 4:04 PM
HonFu
HonFu - avatar