this is my first attempt on python and i would really love some help heres my code

class Customers(object):
    def __init__(self, Surname = None, FirstName = None, Address = None, Town = None, Postcode = None, PhoneNumber = None, Date = None, Email = None):
        self.Surname = Surname
        self.FirstName = FirstName
        self.Address = Address
        self.Town = Town
        self.Postcode = Postcode
        self.PhoneNumber = PhoneNumber
        self.Date = Date
        self.Email = Email

    def printinfo(self):
        print("Surname:", self.Surname)
        print("FirstName:", self.FirstName)
        print("Address:", self.Address)
        print("Town:", self.Town)
        print("Postcode:", self.Postcode)
        print("Phone Number:", self.PhoneNumber)
        print("Date:", self.Date)
        print("Email:", self.Email)

c = Customers("bob", "Samantha", "2 heather road", "Basingstoke", "RG21 3SD", "01256 135434", "23/04/1973", "")

print ("who are you looking for?") 

myFile = open("Address Book for A453_QP2.csv")
addressbook = []
for eachList in myFile:
    nospaces = eachList.strip()
    addressInfo = eachList.split(",")
    print(addressInfo[0], addressInfo[1], addressInfo[2], addressInfo[3], addressInfo[4], addressInfo[5])
    c = Customers([addressInfo[0], addressInfo[1], addressInfo[2], addressInfo[3], addressInfo[4], addressInfo[5]])

Here is your print function transformed to conform common style rules of PEP8

from __future__ import print_function

class Customers(object):
    def __init__(self, sur_name = None, first_name = None, address = None, town = None, post_code = None, phone_number = None, date = None, email = None):
        self.sur_name = sur_name
        self.first_name = first_name
        self.address = address = town
        self.post_code = post_code
        self.phone_number = phone_number = date = email

    def __str__(self):
        return """\
Surname:      %s
FirstName:    %s
Address:      %s
Town:         %s
Postcode:     %s
Phone Number: %s
Date:         %s
Email:        %s""" % (self.sur_name, self.first_name, self.address,, self.post_code, self.phone_number,,

c = Customers("bob", "Samantha", "2 heather road", "Basingstoke", "RG21 3SD", "01256 135434", "23/04/1973", "")

Edited 2 Years Ago by pyTony

This article has been dead for over six months. Start a new discussion instead.