Repeated Start
Sometimes you need to check whether the beginning of a string appears again at the end, which helps find simple patterns and matches. Write a function front_again that takes a string s and compares its first two characters with its last two characters. Return True if they are the same, otherwise return False.
Примеры
Ввод
"edited"Вывод
TrueВвод
"edit"Вывод
FalseВвод
"ed"Вывод
TrueНужно реализовать
def front_again(s: str) -> bool:
Теги
strings
Melde dich an, um den Einreichungsverlauf zu sehen
AnmeldenMelde dich an, um den KI-Mentor zu nutzen
AnmeldenVisible tests
1
Input
"edited"Expected
True2
Input
"edit"Expected
False3
Input
"ed"Expected
True4
Input
"abcab"Expected
True5
Input
"a"Expected
False6
Input
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"Expected
TrueFocus radio
Paused · SomaFM · Fluid