23 lines
735 B
Python
23 lines
735 B
Python
# HumanEval/134
|
|
# Loki Mode Multi-Agent Solution
|
|
# Attempts: 1
|
|
# Passed: True
|
|
|
|
def check_if_last_char_is_a_letter(txt):
|
|
'''
|
|
Create a function that returns True if the last character
|
|
of a given string is an alphabetical character and is not
|
|
a part of a word, and False otherwise.
|
|
Note: "word" is a group of characters separated by space.
|
|
|
|
Examples:
|
|
check_if_last_char_is_a_letter("apple pie") ➞ False
|
|
check_if_last_char_is_a_letter("apple pi e") ➞ True
|
|
check_if_last_char_is_a_letter("apple pi e ") ➞ False
|
|
check_if_last_char_is_a_letter("") ➞ False
|
|
'''
|
|
if not txt or not txt[-1].isalpha():
|
|
return False
|
|
if len(txt) == 1:
|
|
return True
|
|
return txt[-2] == ' ' |