-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex2-1.py
More file actions
25 lines (20 loc) · 857 Bytes
/
ex2-1.py
File metadata and controls
25 lines (20 loc) · 857 Bytes
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
__author__ = 'Administrator'
def get_capital(country):
countries = {'Canada': 'Ottawa', 'Greece': 'Athens', 'France': 'Paris',
'Germany': 'Berlin', 'Japan': 'Tokyo', 'Spain': 'Madrid',
'Norway': 'Oslo'}
for item in countries:
if country == item:
return countries[item]
print(get_capital('Spain'))
print('------------------//----------------')
def longer(country1, country2):
if len(country1) > len(country2):
return country1
elif len(country1) < len(country2):
return country2
else:
print('They are equal')
print(longer('hello man', 'hello man'))
print('------------------//----------------')
print('The longer string comparing the ' + get_capital('Japan') + ' and ' + get_capital('Greece')+ ' is ' + longer(get_capital('Japan'), get_capital('Greece')))