Question: Write a python function that takes as input a string and returns an integer that represents the sum of the word, such as the rank

Write a python function that takes as input a string and returns an integer that represents the sum of the word, such as the rank of each letter in the alphabet represents its value. However, if the string contains 3 times the same letter, if the repeated letter is an "a" the function will return the sum of the other letters + 500, if not, it will return the sum of the other letters + 100. Also, if the letters are in a consecutive order the function will return 300, and if the only letter in the string is "a" or "z" the function will return 50. You are not allowed to use any dictionary dict(), or lambda, or set(), or all...etc. Keep it simple please.

The function has to look like this:

>>> value_of_word("abc"):

300

>>> value_of_word("a"):

50

>>> value_of_word("rarer")

106

>>> value_of_word("banana")

516

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!