Added code for lecture 2026-11-10
This commit is contained in:
parent
5b630435ae
commit
07b9e54bf0
52 changed files with 1248 additions and 1 deletions
21
lecture20261110/contacts_directory/listvsdictionary.py
Normal file
21
lecture20261110/contacts_directory/listvsdictionary.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
|
||||
from pprint import pprint
|
||||
|
||||
addressList = ["John Smith", "1 Main St", "Anycity", "Ma", "01102"]
|
||||
|
||||
print(addressList)
|
||||
|
||||
print(sorted(addressList))
|
||||
|
||||
addressDictionary = {'Name':"John Smith", 'Address':"1 Main St", 'City': "Anycity",
|
||||
'State':"Ma", 'ZipCode': "01102"}
|
||||
|
||||
print(addressDictionary)
|
||||
|
||||
print(addressDictionary.keys())
|
||||
print(addressDictionary.values())
|
||||
|
||||
for Item in addressDictionary.keys():
|
||||
print(f"{Item:10s} {addressDictionary[Item]}")
|
||||
|
||||
pprint(addressDictionary)
|
||||
Loading…
Add table
Add a link
Reference in a new issue