'^([A-Za-z0-9 ]+),([A-Za-z0-9 ]+),([0-9 ]+),([0-9 ]+),([0-9 ]+)$') for n in range(len(all_lines)): house = pattern.search(all_lines[n]) if house: if house[5].strip() == '0': # create lease object with house strips myLease[leaseHouseNumber] = Classes.Lease(house[1].strip(), house[2].strip(), float(house[3].strip()), float(house[4].strip()), float(house[5].strip())) leaseHouseNumber += 1 else: # create airbnb objects with house strips. myAirBNB[airBNBHouseNumber] = Classes.AirBNB( house[1].strip(), house[2].strip(), float(house[3].strip()), float(house[4].strip()), float(house[5].strip())) airBNBHouseNumber += 1 pass else: print("You encountered some mistake in separation of each line.") def getEarnings(myLeaseC, myAirBNBC): earnings = {} for n in range(len(myLeaseC)): # print("Monthly Earnings of house: \" {} \" are : {} ". format(myLease[n].getName(), myLease[n].getQuota())) earnings[n] = myLeaseC[n].getQuota() for i in range(len(myAirBNBC)): # print("Monthly Earnings of house: \" {} \" are : {} ".format(myAirBNB[n].getName(), myAirBNB[n].getQuota()))