Let’s say I have this string:
"""line1
line2
line3
line4
line5
line6
line7
line8"""
I want to write a function to split it into two equal-sized columns represented by a single string, like so:
"""line1 line5
line2 line6
line3 line7
line4 line8"""
I can split the string in two like this:
s1,s2 = s[:len(s)//2], s[len(s)//2:]
But then I’m unsure on how to combine them…
Take what you’ve got and then:
Nasty one-liner, but that’s the basic premise, just use
zipto pair the sequence items up and then you canjointhem back together.