if in countscounts[ + elsecounts[ return counts if you know bit more about the python standard libraryyou might prefer to write the same thing more brieflyfrom collections import defaultdict def get_counts (sequence)counts defaultdict(intvalues will initialize to for in sequencecounts[ + return counts put this logic in function just to make it more reusable to use it on the time zonesjust pass the time_zones listin [ ]counts get_counts(time_zonesin [ ]counts['america/new_york'out[ ] in [ ]len(time_zonesout[ ] if we wanted the top time zones and their countswe have to do little bit of dictionary acrobaticsdef top_counts(count_dictn= )value_key_pairs [(counttzfor tzcount in count_dict items()value_key_pairs sort(return value_key_pairs[- :we have thenin [ ]top_counts(countsout[ ][( 'america/sao_paulo')( 'europe/madrid')( 'pacific/honolulu')( 'asia/tokyo')( 'europe/london')( 'america/denver')( 'america/los_angeles')( 'america/chicago')( '')( 'america/new_york') introductory examples www it-ebooks info