Text Start

Programs often need to quickly take the beginning of a text, such as a short prefix, the first letters of a name, or part of a code. Write a function first_two that takes a string s and returns its first two characters. If the string has fewer than two characters, return the whole string.

Примеры

Ввод
"Hello"
Вывод
"He"
Ввод
"abcdefg"
Вывод
"ab"
Ввод
"ab"
Вывод
"ab"

Нужно реализовать

def first_two(s: str) -> str:

Теги

strings
PostgreSQLv16
Entre para enviar

O resultado da execução do código aparecerá aqui

Visible tests
1
Input
"Hello"
Expected"He"
2
Input
"abcdefg"
Expected"ab"
3
Input
"ab"
Expected"ab"
4
Input
"a"
Expected"a"
5
Input
""
Expected""
6
Input
"abc"
Expected"ab"
Focus radio
Paused · SomaFM · Fluid