Nested for Loop runs only once on map

Here is my code:
dataset=[[1, 3, 4], [2, 3, 5], [1, 2, 3, 5], [2, 5]]

c1=[]

for tran in dataset:
for item in tran:
if [item] not in c1:
c1.append([item])

c1=c1.sort()
D=map(frozenset,c1)

for tid in dataset:
print(tid)
for c in D:
print(tid)
print(c)
if c.issubset(tid):
sscnt.setdefault(c,0)
sscnt[c]+=1

Now this "for c in D" nested for loop runs only for first set of dataset value ie [1,3,4].Its doesnt get inside the nested for loop for the rest.Please help.My output looks like this:
[1, 3, 4]
frozenset({1})
[1, 3, 4]
frozenset({3})
[1, 3, 4]
frozenset({4})
[1, 3, 4]
frozenset({2})
[1, 3, 4]
frozenset({5})
[2, 3, 5]
[1, 2, 3, 5]
[2, 5]

and sscnt={frozenset({4}): 1, frozenset({3}): 1, frozenset({1}): 1}

Please help

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories