Text Prefix

Real programs often need to quickly take the beginning of some text, such as the first letters of a name, a country code, or a short prefix. 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 unchanged.

Примеры

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

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

def first_two(s: str) -> str:

Теги

strings
PostgreSQLv16

Your code output will appear here

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
"HELLO"
Expected"HE"
Focus radio
Paused · SomaFM · Fluid