Dictionaries, hurricane analysis

https://www.codecademy.com/journeys/data-scientist-ml/paths/dsmlcj-22-data-science-foundations/tracks/dsmlcj-22-python-fundamentals-for-data-science-part-ii/modules/dsf-python-dictionaries-d9dae807-d0bc-44d8-9687-c54014ef3f24/projects/hurricane-analysis

Preformatted text

1

Update Recorded Damages

conversion = {“M”: 1000000,
“B”: 1000000000}

updated_damages =

test function by updating damages

for entry in damages:
if entry != “Damages not recorded”:
numbers =
for letter in entry:
if letter != “M” and letter != “B”:
numbers.append(letter)
else:
number = “”.join(numbers)
number = number * conversion[letter]
updated_damages.append(number)
else:
updated_damages.append(entry)

print(updated_damages)

When I run this code, I don’t get any errors but nothing prints to the screen. What am I doing wrong, what’s going on?

This line is making the issue.
You can’t multiply the number string by a integer.
Put it in a float() and everything will be alright

1 Like

Thank you so much!

Don’t suppose you know what I’m doing wrong here do you? I keep getting a syntax error but it won’t tell me specifically where the syntax error is.

# 2 
# Create a Table

# Create and view the hurricanes dictionary
hurricanes = {}

for i in names:
  hurricanes[i]=("Name": names[i], "Month": months[i], "Year": years[i], "Max Sustained Wind": max_sustained_winds[i], "Areas Affected": areas_affected[i], "Damage": updated_damages[i], "Deaths": deaths[i])

print(hurricanes)

You’re welcome,
firstly the syntax error, tuples are unable to save key-value pairs and you should use curly brackets instead of parentheses after

hurricanes[i]=

second error is you are using names list values as index of other lists!
use this code instead

for i in range(len(names)):

2 Likes