给定一个字符串,将它们其中的每个字符(区分大小写)再重复一次。
示例:
输入:"Hogwarts"
,输出:"HHooggwwaarrttss"
题目难度:简单
题目来源:CodeWar:Double Char
def solution(words: str) -> str:
# your code here
assert solution("Hogwarts") == "HHooggwwaarrttss"
assert solution("String") == "SSttrriinngg"
assert solution("1234!_ ") == "11223344!!__ "
Kawi
2
return ''.join(i * 2 for i in words)
def solution(words: str) -> str:
s = ""
for i in words:
s += i*2
return s
assert solution("Hogwarts") == "HHooggwwaarrttss"
assert solution("String") == "SSttrriinngg"
assert solution("1234!_ ") == "11223344!!__ "
def solution(words: str) -> str:
return ''.join([words[i]*2 for i in range(len(words))])
assert solution("Hogwarts") == "HHooggwwaarrttss"
assert solution("String") == "SSttrriinngg"
assert solution("1234!_ ") == "11223344!!__ "