Python - 28

Python - 28: Building a Contact Manager

Let's build a simple contact manager using dictionaries, lists, loops, and functions.

✦ Python Editor
▶ Output

👀 Show Example Solution
friends = []

def add_friend(name, city):

    friend = {
        "name": name,
        "city": city
    }

    friends.append(friend)

add_friend("Jamie", "Miami")

add_friend("Chris", "Seattle")

for friend in friends:

    print(friend["name"])

    print(friend["city"])

    print("---")