- The dictionary contains a pair of data enclosed in curly braces, with each pair of data separated by a colon.
- When using print and f to print data, if you encounter something like myname["name"], directly printing it will cause an error. You need to use single quotes to start and end, or change the variable to single quotes here.
- Numeric values defined in curly braces do not need curly braces when printing, use square brackets instead.
- Today's exercise is to create a contact card and print it in a visually appealing way. It's not difficult!
import time
print("🌟Contact Card🌟")
print()
name = input("Input your name: ")
date = input("Input your date of birth: ")
telephone = input("Input your telephone number: ")
email = input("Input your email: ")
address = input("Input your address: ")
Contact_Card = {"name":name,"date":date,"telephone":telephone,"email":email,"address":address}
time.sleep(2)
print("-----------------------------")
print(f"Name: {Contact_Card['name']}\nDOB: {Contact_Card['date']}\nTel:{Contact_Card['telephone']}\nEmail:{Contact_Card['email']}\nAddress: {Contact_Card['address']}")