Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
lists Name Address Phone
#1
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?
Reply
#2
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
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply
#3
Thanks menator01. I think that is what I am looking for.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Microsoft text phone verifying account cito 2 1,002 Jul-21-2022, 12:16 PM
Last Post: cito
  Send SMS from my phone number aster 3 2,743 Jul-03-2021, 02:34 PM
Last Post: ndc85430
  Split dict of lists into smaller dicts of lists. pcs3rd 3 2,401 Sep-19-2020, 09:12 AM
Last Post: ibreeden
  Access phone via Bluetooth maxwell 2 2,295 Jun-03-2020, 05:22 PM
Last Post: maxwell
  Phone numbers ovidius80 2 2,057 Mar-12-2020, 07:08 PM
Last Post: Larz60+
  Phone Number metro17 3 2,662 Aug-22-2019, 09:20 AM
Last Post: perfringo
  Phone app from python code Androsmeq 1 2,248 Mar-29-2019, 05:16 PM
Last Post: gruntfutuk
  sort lists of lists with multiple criteria: similar values need to be treated equal stillsen 2 3,300 Mar-20-2019, 08:01 PM
Last Post: stillsen
  Trying to move a RGB ledstrip with slider of my phone in almost "realtime" help Edris89 0 1,972 Sep-28-2018, 11:03 PM
Last Post: Edris89

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020