Difference between map and dict

Map is not a datatype in python. It applies a function to a series of values and returns the result.

>>> def f(x):
...     return x**2
... 
>>> list(map(f, range(5)))
[0, 1, 4, 9, 16]

Often for a simple case like that to be “pythonic” we use list comprehensions.

>>> [x**2 for x in range(5)]
[0, 1, 4, 9, 16]

You are right in your comparison of hashmaps and dicts.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)