I want to make a list of models with list comprehisions. This is my code:
class customers(object):
def __init__(self,firstname,lastname):
self.firstname = firstname
self.lastname = lastname
firstnames = ["aria", "ali", "behzad", "ahmad", "mohammad", "naser", "reza", "amirmohammad"]
lastnames = ["banazadeh", "raiis", "rohani", "mahmod", "ahmady", "nejad", "alipor","behzadi"]
simplelist = [customers(firstname,lastname) for firstname in firstnames for lastname in lastnames]
for i in simplelist:
print(i.firstname)
print(i.lastname)
When I try to run this, the result is not what i want. The result is:
aria
banazadeh
aria
raiis
aria
rohani
ali
banazadeh
ali
raiis
ali
rohani
behzad
banazadeh
behzad
raiis
behzad
rohani
I want to only make customers with firstname and lastname quick and the result must be this:
aria
banazadeh
ali
raiis
behzad
rohani
Please help.