Python Forum

Full Version: lists Name Address Phone
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello all,

I reviewed a couple online courses in Python and wrote a few short programs. So I am very new to Python

As far as lists know. I know how to make a list of names. How would I make a list with a person's name, address and phone number?
Maybe not the best example

mylist = [['John Doe', 'some street address', '123 456 7890'],['Jane Doe','another street address','987 555 1234']]

for name, address, phone in mylist:
    print(f'Name: {name} Address: {address} Phone: {phone}')
Output:
Name: John Doe Address: some street address Phone: 123 456 7890 Name: Jane Doe Address: another street address Phone: 987 555 1234
Another way

mylist = [
    {'name':'John Doe', 'address':'Some address','phone':'123 456 7897'},
    {'name':'Jane Doe', 'address':'another address','phone':'123 555 1230'}
]

for var in mylist:
    print(f"Name: {var['name']} Address: {var['address']} Phone: {var['phone']}")
Output:
Name: John Doe Address: Some address Phone: 123 456 7897 Name: Jane Doe Address: another address Phone: 123 555 1230
Thanks menator01. I think that is what I am looking for.