반응형
Create a function that returns the CSV representation of a two-dimensional numeric array.
Example:
input:
[[ 0, 1, 2, 3, 4 ],
[ 10,11,12,13,14 ],
[ 20,21,22,23,24 ],
[ 30,31,32,33,34 ]]
output:
'0,1,2,3,4\n'
+'10,11,12,13,14\n'
+'20,21,22,23,24\n'
+'30,31,32,33,34'
Array's length > 2.
Solution:
def to_csv_text(array):
return '\n'.join(','.join(map(str, i)) for i in array)
반응형
'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글
1229. Parts of a list (0) | 2022.12.30 |
---|---|
1228. Kata Example Twist (0) | 2022.12.28 |
1226. Alphabet war (0) | 2022.12.27 |
1225. Switcheroo (0) | 2022.12.25 |
1224. Regex count lowercase letters (0) | 2022.12.25 |