I have a class called Person formatted like this:
class Person:
def __init__(self, first, last, number, zip):
self.first = first
self.lst = last
self.number = number
self.zip = zip
I have a list of Person's called People
People = []
person1, person2
people.append(person1)
people.append(person2)
I want to create a new list that contains all numbers in People in the same order that they appear in People. Currently my solution is to do this:
numbers = []
for person in People:
numbers.append(person.number)
Is this the quickest way to achieve this? Or is there a more efficient/python-like way to do this?