Список 'a', 'b', '_', 'c', 'd' в строку ab cd
Нужно список ['a', 'b', '_', 'c', 'd'] превратить в строку - "ab cd". Если это вообще возможно. Если не возможно, то скажите пожалуйста, как бы вы решили эту задачу:
Split the string into pairs of two characters. If the string contains an odd number of characters, then the missing second character of the final pair should be replaced with an underscore ('_').
Input: A string.
Output: An iterable of strings.
Precondition: 0<=len(str)<=100
Ответы (1 шт):
Автор решения: Yanun
→ Ссылка
Здравствуйте это можно решить вот так
a = ['a', 'b', '_', 'c', 'd']
b = "".join(a).replace("_", " ")
print(b)
join - объединяем строку replace - меняем "_" на пробел