[Chicago] List comprehension question

Tanya Schlusser tanya at tickel.net
Fri May 27 12:00:30 EDT 2016


>  If I use:
>
>  comm = [s for x in c.fetchall()]
>
>  I end up with a list of tuples. Any suggestions as to how I could do
>  this without using a for loop?

You did it! That's a list comprehension 🎉
It has a `for' in the syntax:
https://docs.python.org/3/tutorial/datastructures.html#list-comprehensions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/chicago/attachments/20160527/df8d367e/attachment.html>


More information about the Chicago mailing list