xs = [10,20,30]
xs.append(40)
xs
phones = { "John" : ["111-1234","111-1235"], "Alice": ["333-3333"] }
addresses = { "John" : "123 main street", "Alice": "101 elm street" }
print(phones)
print(addresses)
contacts = {
"John" : {"phone":["111-1234","111-1235"],"address": "123 main street"},
"Alice": {"phone":["333-3333"],"address": "101 elm street"}
}
print(contacts)
contacts["John"]["phone"][0][0]
def find_person_give_phone(contacts,pno): ???
phones["David"] = ["222-2221","222-2222","222-2223"]
print(phones)
contacts["Alice"]["phone"] = contacts["Alice"]["phone"] + ["333-3334"]
print(contacts)
import sys
def get_counts(fname):
# this function takes the name of a file as input parameter, fname
# it then reads the file into a string variable
# then proceeds to process the string for the count of letters
# answer should be returned in a dictionary object
with open(fname,'r') as f:
data = f.read().lower()
d = {}
for c in data:
if c in "abcdefghijklmnopqrstuvwxyz":
if c in d:
d[c] = d[c] + 1
else:
d[c] = 1
return d
def main():
#counts = get_counts(sys.argv[1])
counts = get_counts("ra.txt")
print(counts)
for c in counts:
print(c," : ",counts[c])
main()