二手产品经理

二手产品经理

THIS IS RENO

Dictionary - 40 days - Learn Python online for 100 days

Catbox

  1. The dictionary contains a pair of data enclosed in curly braces, with each pair of data separated by a colon.
  2. 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.
  3. Numeric values defined in curly braces do not need curly braces when printing, use square brackets instead.
  4. 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']}")
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.