The solution here is:
def highest_scoring_word(s):
def word_score(word):
# Calculate the score of a word by summing the position values of its characters
return sum(ord(char) - ord('a') + 1 for char in word)
words = s.split() # Split the input string into words
max_score = 0
highest_word = ""
for word in words:
score = word_score(word)
# Update the highest word if the current word has a higher score
if score > max_score:
max_score = score
highest_word = word
# If scores are equal, keep the first occurring word
elif score == max_score and highest_word == "":
highest_word = word
return highest_word
# Example usage:
input_string = "abad ace bat cat"
print(highest_scoring_word(input_string)) # Output: "ace"