Modifying nested lists
nested-lists, python
Solution
>>> l = [[1, 2, 3], [5, 6, 7]]
>>> [[e*e for e in m] for m in l]
|-nested list-|
|---- complete list ---|
[[1, 4, 9], [25, 36, 49]]
Problem
How to handle nested lists in Python? I am having problem figuring out the syntax. Like example: ``` >>> l = [[1, 2, 3], [5, 6, 7]] ``` I want to square all the elements in this list. I tried: ``` [m*m for m in l] ``` But that doesn't work and throws up: TypeError: can't multiply sequence by non-int of type 'list' because of the nested lists I guess? How do I fix this?