I have two strings:
s1 = '''One scientist
said'''
s2 = 'One man said'
I need to put '\n' sign instead space in s2 after second word as in s1. Lika that:
s2 = '''One man
said'''
But how I can do it?
CodePudding user response:
Try this:
s2 = 'One man said'
x = s2.split()[:2] # First two words
y = s2.split()[2:] # After first two
text_to_add = '\n ' # Change if you want
out = x text_to_add y
print(out)
CodePudding user response:
Try this solution, it's really simple
s2 = 'One man\n said'