При самостоятельном запуске выдаёться результат соответствующий требованиям теста, но он выдаёт ошибку тестирования
# Написать функцию high_score, которая из строки слов возвращает слово с максимальным количеством очков.
# Очки считаются по буквам, где a = 1, b = 2, c = 3, d = 4, ...
#
# Примеры:
# high_score("abc aaf") == "aaf" ("abc"= 1+2+3 = 6, "aaf" = 1+1+6 = 8)
import traceback
def high_score(s):
alphabet = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
cc1=0
cc2=0
cb=0
mcb=0
pr=" "
r=" "
while cc1<len(s):
cc2=0
while cc2<=len(alphabet):
if s[cc1] == alphabet[cc2]:
cb=cb+cc2+1
pr=pr+s[cc1]
break
if s[cc1] == " ":
if mcb<cb:
r=pr.lstrip(" ")
mcb=cb
pr=" "
cb=0
break
cc2=cc2+1
cc1=cc1+1
if mcb<cb:
r=pr.lstrip(" ")
mcb=cb
print(r)
return 'r'
# Тесты
try:
assert high_score('abcd ef') == 'ef'
assert high_score('what time are we climbing up the volcano') == 'volcano'
assert high_score('zcfjyj ivsrnnelok gfuckq puhid xxituwu lzs bbzkyb kqvg kmfvfg') == 'xxituwu'
assert high_score('qjfxvxb pgtkr dhojthinm dyr cjne') == 'qjfxvxb'
except AssertionError:
print("TEST ERROR")
traceback.print_exc()
else:
print("TEST PASSED")
# Написать функцию high_score, которая из строки слов возвращает слово с максимальным количеством очков.
# Очки считаются по буквам, где a = 1, b = 2, c = 3, d = 4, ...
#
# Примеры:
# high_score("abc aaf") == "aaf" ("abc"= 1+2+3 = 6, "aaf" = 1+1+6 = 8)
import traceback
def high_score(s):
alphabet = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
cc1=0
cc2=0
cb=0
mcb=0
pr=" "
r=" "
while cc1<len(s):
cc2=0
while cc2<=len(alphabet):
if s[cc1] == alphabet[cc2]:
cb=cb+cc2+1
pr=pr+s[cc1]
break
if s[cc1] == " ":
if mcb<cb:
r=pr.lstrip(" ")
mcb=cb
pr=" "
cb=0
break
cc2=cc2+1
cc1=cc1+1
if mcb<cb:
r=pr.lstrip(" ")
mcb=cb
print(r)
return 'r'
# Тесты
try:
assert high_score('abcd ef') == 'ef'
assert high_score('what time are we climbing up the volcano') == 'volcano'
assert high_score('zcfjyj ivsrnnelok gfuckq puhid xxituwu lzs bbzkyb kqvg kmfvfg') == 'xxituwu'
assert high_score('qjfxvxb pgtkr dhojthinm dyr cjne') == 'qjfxvxb'
except AssertionError:
print("TEST ERROR")
traceback.print_exc()
else:
print("TEST PASSED")