I get error printing result.age Why? How I can fix it?
import random
names = ['Bob', 'Robert', 'Tom']
result = random.choices(names, weights=[5, 10, 12], k=random.randint(1, 3))
print(result)
class People:
def __init__(self, age, city):
self.age = age
self.city = city
Bob = People('23', 'NewYork')
Robert = People('73', 'Boston')
Tom = People('43', 'Oslo')
print(result.age)
Thx for any help.
Aucun commentaire:
Enregistrer un commentaire