Medical Insurance Project > 'NoneType' object is not iterable'?

Hello everyone,

In the excercise below I’m trying to create a for loop that sorts through a string and counts the number of medical records by adding the count of ‘#’ to a list:

updated_medical_data = print(medical_data.replace('#','$'))

num_records = 0

for i in updated_medical_data:
  if i == '$':   
    num_records += 1

However, when I execute this code it gives the error message: ‘for i in updated_medical_data:
TypeError: ‘NoneType’ object is not iterable’.

Does anyone know how to solve this? :slight_smile: It would be much appreciated!

Heya! welcome :smiley:

This line here is where the problem happens:

updated_medical_data = print(medical_data.replace('#','$'))

You are assigning the return value of the print function, which is None. The line below should give you the desired result.

updated_medical_data = medical_data.replace('#','$')

good luck learning :slight_smile:

Ah I get it. Thank you!