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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started