Remove One Character
Removing one character from a string is common when cleaning text or fixing a typo. Write a function missing_char that takes a non-empty string s and a valid index n. Return a new string where the character at position n is removed, and all other characters stay in the same order.
Примеры
Ввод
"kitten", 1Вывод
"ktten"Ввод
"kitten", 0Вывод
"itten"Ввод
"kitten", 4Вывод
"kittn"Нужно реализовать
def missing_char(s: str, n: int) -> str:
Теги
strings
Log ind for at se indsendelseshistorik
Log indLog ind for at bruge AI-mentor
Log indVisible tests
1
Input
"kitten", 1Expected
"ktten"2
Input
"kitten", 0Expected
"itten"3
Input
"kitten", 4Expected
"kittn"4
Input
"chocolate", 8Expected
"chocolat"5
Input
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", 8Expected
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"6
Input
"kitten", 100Expected
"kitten"Focus radio
Paused · SomaFM · Fluid