List Comprehension
This is not list comprehension.
List comprehesion for example:
lst2 = [x for x in lst1 if x % 2 == 0]
Where lst1
is a list and we filter in only values that are even if x % 2 == 0
and assign it to list lst2
.
Meaning of counts[num]=counts.get(num,0)+1
counts.get(num,0)
get value ofnum
key fromcounts
dictionary, if key not exists return0
- So
counts[num]=counts.get(num,0)+1
would result in increasingcounts[num]
by one (and if not exists would by set to one)
3
solved What does list comprehension “counts[num]=counts.get(num,0)+1” mean? [closed]