I had a section of my code that worked to create 3 attributes of a class, self.first_name, self.last_name, and self.email:
self.first_name = input("First name: ")
self.last_name = input("Last name: ")
self.email = input("Email: ")
And basically just noticed that I was repeating myself and could probably do this more efficiently using a for loop and a list of the attributes. So I tried this:
attrs = ["first_name", "last_name", "email"]
for attr in attrs:
self.attr = input(f"{attr} :")
This doesn't quite have the desired effect, I think here every attribute is self.attr rather than the intended names. Can anyone suggest a way to fix this? I'm sure there must be a better way than writing it out every time.