0
Whats the logic of print the answer out?
scores = [88,90,40,60,65,91,98] a_score = filter(lambda i : True if i >= 90 else False, scores) for k in a_score: print(k) Whyl it would result an error if directly print the "a_score" out, as well as need to use for..in loop to print it out?
4 Answers
+ 1
a_score is not a list, so you cannot print it directly until a conversion. This is also mentioned in the lessons
https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2461/
+ 1
It creates a filter object (like a generator) and not a list. Remember that such objects are iterable (but cannot be indexed). You need to make it into a list to print it out.
a_score = list(filter( ... ))
+ 1
CarrieForle I see, I havent been there (the lesson)before. Thanks a lot!
+ 1
Abhinav Anand Good! Thank you so much!