반응형
Given a string, you have to return a string in which each character (case-sensitive) is repeated once.
Examples (Input -> Output):
* "String" -> "SSttrriinngg"
* "Hello World" -> "HHeelllloo WWoorrlldd"
* "1234!_ " -> "11223344!!__ "
Good Luck!
Solution:
def double_char(s: str) -> str:
return "".join((lambda x: x+x)(i) for i in s)
반응형
'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글
1012. All Star Code Challenge #18 (0) | 2022.10.12 |
---|---|
1011. Square(n) Sum (0) | 2022.10.11 |
1009. Surface Area and Volume of a Box (0) | 2022.10.10 |
1008. Drink about (0) | 2022.10.08 |
1007. Volume of a Cuboid (0) | 2022.10.08 |