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
Logáil isteach chun stair na n-aighneachtaí a fheiceáil
Logáil isteachLogáil isteach chun an Meantóir IS a úsáid
Logáil isteachTests12
Visible tests
Tástáil fholaithe 7
Tástáil fholaithe 8
Tástáil fholaithe 9
Tástáil fholaithe 10
Tástáil fholaithe 11
Tástáil fholaithe 12
They run when you press "Submit" — your whole solution is checked against them so you can't hard-code answers for the visible cases.
Focus radio
Paused · SomaFM · Fluid