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
PostgreSQLv16

Tukaj bo rezultat izvajanja kode

Visible tests
1
Input
"Hello", True
Expected"H"
2
Input
"Hello", False
Expected"o"
3
Input
"oh", True
Expected"o"
4
Input
"oh", False
Expected"h"
5
Input
"hello", False
Expected"o"
6
Input
"ab", True
Expected"a"
Focus radio
Paused · SomaFM · Fluid