-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathex39.py
57 lines (38 loc) · 998 Bytes
/
ex39.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
states = {
'oregonx':'or',
'florida':'fl',
'california':'ca',
'new york':'ny',
'michigan':'mi'
}
cities ={
'ca':'san francisco',
'mi':'detroit',
'fl':'jacksonville'
}
cities['ny'] = 'new york'
cities['or'] = 'portland'
print'-'*10
print "ny state has:",cities['ny']
print "or state has:",cities['or']
print'-'*10
print"michigan's abbreviation is:",states['florida']
print'-'*10
print "michigan has:",cities[states['michigan']]
print "michigan has:",cities[states['florida']]
print'-'*10
for state,abbrev in states.items():
print"%s is abbreviated %s" %(state,abbrev)
print'-' * 10
for abbrev,city in cities.items():
print"%s has the city %s" %(abbrev,city)
print'-' * 10
for state,abbrev in states.items():
print "%s state is abbreviated %s and has city %s"%(
state,abbrev,cities[abbrev])
print'-' * 10
state = states.get('texas',None)
if not state:
print "sorry ,no texas"
city = cities.get('tx','does not exist')
print"the city for the state 'tx' is: %s" %city