Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

vasudevram vasudevram at gmail.com
Fri Mar 21 16:56:09 EDT 2014


On Saturday, March 22, 2014 2:24:00 AM UTC+5:30, Rustom Mody wrote:
> Lets try without comprehending comprehensions :-) 
> >>> x=[[1,2],[3,4]]
> 
> >>> for x in x:
> 
> ...   for x in x:
> 
> ...      print x
> 
> ... 
> 
> 1
> 
> 2
> 
> 3
> 
> 4

Nice and all, thanks, but doesn't answer the question.




More information about the Python-list mailing list