0
how to split one line in two different lines?
10 Respostas
+ 2
from start to 3 [:3]
from3 to end [3:]
+ 2
add \n where you want to split
str="onetwothree"
str= str[:3] + "\n" + str[3:6] + "\n" + str[6:]
print(str)
+ 1
insert \n where you want to split
d="hello world"
dl = list(d)
dl.insert(6,"\n")
d=''.join(dl)
print(d)
+ 1
str = "go split"
str = str[:3] + "\n" + str[3:]
print(str)
+ 1
print("hello \n world")
0
Will try this out.
But is this the only way?
0
thanks that worked.
0
can u explain dat:3 and 3: means?
0
what if i have three words n split them in three different lines. how will it work? i mean:3 &3: wont work.
0
minakshi Singh, he asked how to split one string to two lines. So you have string object that already exist and now split it, not in the first asignment.