-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhigh.py
More file actions
executable file
·25 lines (20 loc) · 769 Bytes
/
Copy pathhigh.py
File metadata and controls
executable file
·25 lines (20 loc) · 769 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
#!/usr/bin/python
import string
def high(x):
values = dict()
for index, letter in enumerate(string.ascii_lowercase):
values[letter] = index + 1
words = x.split()
score_card = list()
for word in words:
word_score = 0
for c in list(word):
word_score = word_score + values[c]
score_card.append(word_score)
return words[score_card.index(max(score_card))]
print high('man i need a taxi up to ubud')
print high('what time are we climbing up the volcano')
##### Rules
#Given a string of words, you need to find the highest scoring word.
#Each letter of a word scores points according to it's position in the alphabet: a = 1, b = 2, c = 3 etc.
#You need to return the highest scoring word as a string.