for learning, i had to create a class User, use that class to create objects and finally add them to another list via a for loop. but the result sent are unexpected and totally different from waht i wanted. here's the class:
class User:
def __init__(self, firstname : str='', lastname: str = '', email: str='', newsletter : boolean = False):
self.firstname = firstname,
self.lastname = lastname,
self.email = email,
self.newsletter = newsletter
and here are the objects:
new_users = [
User('Joe', 'Dalton', '[email protected]', True),
User('William', 'Dalton', '[email protected]'),
User('Jack', 'Dalton', '[email protected]'),
User('Averell', 'Dalton', '[email protected]', True)
]
the loop is right here:
users = []
for i in range (len(new_users)):
users.append(str(new_users))
print(users)
here's what i have in the terminal:
['[<__main__.User object at 0x7f4c363da1f0>, <__main__.User object at 0x7f4c363c2f10>, <__main__.User object at 0x7f4c3639b9a0>, <__main__.User object at 0x7f4c36326250>]', '[<__main__.User object at 0x7f4c363da1f0>, <__main__.User object at 0x7f4c363c2f10>, <__main__.User object at 0x7f4c3639b9a0>, <__main__.User object at 0x7f4c36326250>]', '[<__main__.User object at 0x7f4c363da1f0>, <__main__.User object at 0x7f4c363c2f10>, <__main__.User object at 0x7f4c3639b9a0>, <__main__.User object at 0x7f4c36326250>]', '[<__main__.User object at 0x7f4c363da1f0>, <__main__.User object at 0x7f4c363c2f10>, <__main__.User object at 0x7f4c3639b9a0>, <__main__.User object at 0x7f4c36326250>]']