Post

Nice use of map().
Another common Pythonic option here is list comprehension:
squares = [n ** 2 for n in nums]
I ran a small timeit comparison:
for loop + append → 1.1768
map(...) → 1.0982
list comprehension → 0.7580
So for this simple transformation, I’d probably choose the list comprehension.
#Python #PythonCode #Coding #Programming #CodeNewbie #100DaysOfCode
English

