错误:
TypeError:object of type ‘map’ has no len()
The map in python 3 has no len function.
Solution:
x = [[1, 'a'], [2, 'b'], [3, 'c']]
len(map(lambda a: a[0], x))
- Talk about forced conversion of map to list or tuple, and then find len
len(list(map(lambda a: a[0], x)))
- Use list comprehension, don't use map
my_list = [a[0] for a in x]
len(my_list)