lundi 23 septembre 2019

Dict Comprehension with Random Module

I am trying to generate a dict with a random.randint()

O = range(1, 6)
R = ['A', 'B', 'C', 'D', 'E']
d = dict(((o, r), random.randint(1, 5)) for o in O for r in R)

However, I am getting the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 1, in <genexpr>
AttributeError: 'builtin_function_or_method' object has no attribute 'randint'




Aucun commentaire:

Enregistrer un commentaire