Choose an End
A boolean flag is often used as a switch that chooses which branch of logic to run. Write a function the_end that takes a non-empty string s and the boolean flag front. If front is True, return the first character of the string; otherwise, return the last character.
Примеры
Ввод
"Hello", TrueВывод
"H"Ввод
"Hello", FalseВывод
"o"Ввод
"oh", TrueВывод
"o"Нужно реализовать
def the_end(s: str, front: bool) -> str:
Теги
strings
Connectez-vous pour voir l'historique des soumissions
Se connecterConnectez-vous pour utiliser le Mentor IA
Se connecterVisible tests
1
Input
"Hello", TrueExpected
"H"2
Input
"Hello", FalseExpected
"o"3
Input
"oh", TrueExpected
"o"4
Input
"oh", FalseExpected
"h"5
Input
"hello", FalseExpected
"o"6
Input
"ab", TrueExpected
"a"Focus radio
Paused · SomaFM · Fluid