vendredi 29 mai 2015

Use list comprehension without iteration variable [duplicate]

This question already has an answer here:

I wonder if there is a way to use e.g. a list comprehension without an iteration variable if I do not need it? For example, in this sample of code:

a = [random.randrange(-10, 11) / 10 for i in range(100)]

I get a warning "Local variable 'i' value is not used". Is there any variant of the list comprehension construct without iteration variable?

Aucun commentaire:

Enregistrer un commentaire