0

Please explain this:

l = {1,2,5,6,1,2,4,6,1} t = tuple(l) Print(t.count(1))

5th May 2020, 12:24 PM
Aditya Singh
Aditya Singh - avatar
4 Respostas
+ 1
So the number of times we insert any number(same) doesn't matter it always stores as a single quantity?
5th May 2020, 12:32 PM
Aditya Singh
Aditya Singh - avatar
+ 1
Okk thanks I understood.
5th May 2020, 12:36 PM
Aditya Singh
Aditya Singh - avatar
0
l is of type set and stores each number only once.
5th May 2020, 12:28 PM
HonFu
HonFu - avatar
0
You should make your questions a bit more clear. I just guess you are wondering why you get output 1? You have a set (l), so each value can be part once or not at all. So when you count the occurence in the created tuple (t) it will return just 0 or 1.
5th May 2020, 12:34 PM
Manu_1-9-8-5
Manu_1-9-8-5 - avatar