assert, and its finally part prints the word.
def check(word):
try:
assert word == word[::-1], "not a palindrome"
return "yes"
except AssertionError as e:
return str(e)
finally:
print(word.upper(), end=" ")
print(check("level"), check("lever"))
What does the program print?Log in to join the discussion.
Loading…