Hi,
I'm learning python and i'm in the process of trying to write an adress book program. I'm using a class to do it all and i'm hopeless at oop. Heres a bit of code:
What i want to know is how to select which added person to delete (at the moment it automatically deletes the most recently added) and how to list all the people.
Thanks
Programming noob Iz
I'm learning python and i'm in the process of trying to write an adress book program. I'm using a class to do it all and i'm hopeless at oop. Heres a bit of code:
Code:
run = 1 class Person: pop = 0 def __init__(self, name): self.name = name Person.pop +=1 def sayHi(self): print 'Hello, my name is', self.name def countPeople(self): print 'There are %d people here' % Person.pop def delPerson(self): del self.name print 'Person deleted' Person.pop -= 1 while run == 1: c = raw_input('Please enter a command:') if c == 'add': p = Person(raw_input('Please enter a name:')) p.sayHi() elif c == 'del': p.delPerson() elif c == 'count': p.countPeople() elif c == 'break': break
Thanks
Programming noob Iz
Comment