-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode_Bird.py
More file actions
37 lines (26 loc) · 860 Bytes
/
code_Bird.py
File metadata and controls
37 lines (26 loc) · 860 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
26
27
28
29
30
31
32
33
34
35
36
37
"""
Write a functon to convert bird names into four letter bird codes .
1. Define a function that takes a string as input.
2. Inside the function, split the bird name into words.
3. If there is only one word, take the first four letters.
4. If there are two words, take the first two letters from each word.
5. If there are three or more words, take the first letter from each of the first
three words and add the first letter of the last word.
6. Return the four-letter bird code in uppercase.
Input : 'Northern Cardinal'
Output : NOCA
Input : 'American Crow'
Output : AMCR
Input : 'Bald Eagle'
Output : BAEA
Input : 'Black-capped Chickadee'
Output : BLCH
"""
def bird_code(name):
st = ''
new = name.split(' ')
for i in new:
st += i[0] + i[1]
print(st.upper())
return st.upper()
print(bird_code('Northan Cardinal'))