#The length of medical records
num_medical_records = len(medical_records)
In the above, medical_records is a zip object, and since it has no len() (meaning we cannot measure its length) calling on that function with the object as the argument will raise an error. It is a TypeError because the function was called on an invalid type (zip).
Casting the zip object to a list, or tuple, will allow us to determine the length since those two types are valid arguments.
zip() it’s a data type itself and we can’t use len() on it. what you can do is type cast your zip() variable into a list! then you’ll be able to use len() on it.
Be sure to assign to a variable, before printing. What that line is doing is consuming the zip object, but not saving it, only printing it. The list vanishes after that.
you consume the zip object assigned to the medical_records variable. But, you have already saved the result to the a variable.
# You wrote:
a = list(medical_records)
print(a)
num_medical_records = len(list(medical_records))
# It should be:
a = list(medical_records)
print(a)
num_medical_records = len(a)
# You could also have done:
medical_records = list(medical_records)
print(medical_records)
num_medical_records = len(medical_records)