1

I wish to create a column from the output of this Python script.

str ='JJHKEKWPWPWJJENNICNRTKMNWAPOHBYEBSWKL'

n = 10
chunks = [str[i:i+n] for i in range(0, len(str), n)]
print(chunks)

Output = ['JJHKEKWPWP', 'WJJENNICNR', 'TKMNWAPOHB', 'YEBSWKL']

So that the final output will be.

JJHKEKWPWP
WJJENNICNR
TKMNWAPOHB
YEBSWKL
james
  • 11
  • 1
  • Does this answer your question? [How can I format a list to print each element on a separate line in python?](https://stackoverflow.com/questions/13443588/how-can-i-format-a-list-to-print-each-element-on-a-separate-line-in-python) – wjandrea Jun 18 '21 at 01:35

1 Answers1

1

You can use the sep parameter from print and the splat operator:

print(*chunks, sep='\n')
enzo
  • 9,861
  • 3
  • 15
  • 38
  • 1
    Thank you so much ...That was the solution I was looking for – james Jun 18 '21 at 01:15
  • @james Glad to help! If my answer helped you, you can accept it by clicking on the big checkmark to select it as the accepted answer, so people answering can focus on older questions which still don't have answers. – enzo Jun 19 '21 at 19:00