On Mon, Jul 30, 2018 at 12:20 PM Valerio Pachera <vale...@pbds.eu> wrote:
> I was looking to substiture the cicle for e in new_d like this:
>   [ new_d[e].append(k) if e in new_d else new_d[e].append(k) for e in d[k] ]
> but it can't work because 'new_d[e] = []' is missing.

Have a look at `dict.setdefault` and play around with it; I think it
will help you do what you want.

-- 
Zach
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to