Hurricane Analysis - mortality scale

Hello. I got lost in this project because I cannot compare outputs that am I right by writingt that code or not. In this project, actually in the 7. point I couldn’t solve the task by myself, so I applied in ChatGPT. However, I am not sure that is it correct output that meet task requirement or not. Could you pls help me?

def rate_hurricanes(deaths, max_sustained_winds): mortality_scale = {0: 0, 1: 100, 2: 500, 3: 1000, 4: 10000} hurricane_ratings = {} for i in range(len(deaths)): mortality_rating = 0 for rating, upper_bound in mortality_scale.items(): if deaths[i] > upper_bound: mortality_rating = rating + 1 hurricane = {'deaths': deaths[i], 'max_sustained_winds': max_sustained_winds[i]} if mortality_rating in hurricane_ratings: hurricane_ratings[mortality_rating].append(hurricane) else: hurricane_ratings[mortality_rating] = [hurricane] return hurricane_ratings deaths = [90,4000,16,3103,179,184,408,682,5,1023,43,319,688,259,37,11,2068,269,318,107,65,19325,51,124,17,1836,125,87,45,133,603,138,3057,74] max_sustained_winds = [165, 160, 160, 175, 160, 160, 185, 160, 160, 175, 175, 160, 160, 175, 160, 175, 175, 190, 185, 160, 175, 180, 165, 165, 160, 175, 180, 185, 175, 175, 165, 180, 175, 160] hurricane_ratings = rate_hurricanes(deaths, max_sustained_winds) print(hurricane_ratings)

or this code is right?

def rate_hurricanes(names, deaths, mortality_scale): rated_hurricanes = {rating: [] for rating in mortality_scale} for name, death_count in zip(names, deaths): for rating, upper_bound in mortality_scale.items(): if death_count <= upper_bound: rated_hurricanes[rating].append({'Name': name, 'Deaths': death_count}) break return rated_hurricanes mortality_scale = {0: 0, 1: 100, 2: 500, 3: 1000, 4: 10000} names = ['Cuba I', 'San Felipe II Okeechobee', 'Bahamas', 'Cuba II', 'CubaBrownsville', 'Tampico', 'Labor Day', 'New England', 'Carol', 'Janet', 'Carla', 'Hattie', 'Beulah', 'Camille', 'Edith', 'Anita', 'David', 'Allen', 'Gilbert', 'Hugo', 'Andrew', 'Mitch', 'Isabel', 'Ivan', 'Emily', 'Katrina', 'Rita', 'Wilma', 'Dean', 'Felix', 'Matthew', 'Irma', 'Maria', 'Michael'] deaths = [90,4000,16,3103,179,184,408,682,5,1023,43,319,688,259,37,11,2068,269,318,107,65,19325,51,124,17,1836,125,87,45,133,603,138,3057,74] rated_hurricanes = rate_hurricanes(names, deaths, mortality_scale) for rating, hurricanes in rated_hurricanes.items(): print("Mortality Rating:", rating) print(hurricanes) print()

the second one is closer to the task’s requirements