reader = csv.reader(f) calls = list(reader) """ TASK 2: Which telephone number spent the longest time on the phone during the period? Don't forget that time spent answering a call is also time spent on the phone. Print a message: "<telephone number> spent the longest time, <total time> seconds, on the phone during September 2016.". """ # Steps: # Get the list of unique numbers from task 1 ListOfUniqueNo, column_search = Task1.task1() callDuration = 0 # Create a map of Unique numbers initialize the value to 0 this is placeholder to add time spent on call map_numbers = dict.fromkeys(ListOfUniqueNo, callDuration) # Update the existing Key value with the sum of prev value + next value def task2_Opt(ListOfUniqueNo, column_search): # O(2n) for i in range(column_search): for row in calls: if row[i] in map_numbers.keys(): x = map_numbers[row[i]] x = x + int(row[3]) map_numbers.update({row[i]: x})