Https://www.codecademy.com/courses/learn-intermediate-python-3/articles/built-in-higher-order-functions-in-python

I am doing a code exercise for the topic " Higher-Order Functions", map().

I’ve checked the answer already and see that the same thing could be written shorter with a lambda function. But still I don’t understand why my version gets an error:

File “challenge1.py”, line 5, in change_grades
for grade in grade_list:
TypeError: ‘float’ object is not iterable

print(change_grades(grade_list)) gives me an output without errors.
print((grades_100scale)) also returns a map object.

Will be grateful for the help. Thanks in advance!

grade_list = [3.5, 3.7, 2.6, 95, 87] def change_grades(grade_list): new_list = [] for grade in grade_list: if grade <= 4: grade = int(grade * 25) new_list.append(int(grade)) return new_list print(change_grades(grade_list)) grades_100scale = map(change_grades, grade_list) print((grades_100scale)) updated_grade_list = list(grades_100scale) print(updated_grade_list)

Oh, I’ve re-read the material of this lesson and noticed my obvious error.
Lesson says:

When called, map() applies the passed function to each and every element in the iterable and returns a map object. The returned map object holds the results from applying the mapping function to each element in the passed iterable.

Placing the working code below in case if somebody else will have the same problem :sweat_smile:

grade_list = [3.5, 3.7, 2.6, 95, 87] def change_grades(grade): if grade <= 4: grade = int(grade * 25) return grade grades_100scale = map(change_grades, grade_list) updated_grade_list = list(grades_100scale) print(updated_grade_list)