0

how to split one line in two different lines?

11th Aug 2016, 6:55 AM
Sandeep Sreenivasanunni
Sandeep Sreenivasanunni - avatar
10 Respostas
+ 2
from start to 3 [:3] from3 to end [3:]
12th Aug 2016, 6:32 AM
‫Ido Tal
‫Ido Tal - avatar
+ 2
add \n where you want to split str="onetwothree" str= str[:3] + "\n" + str[3:6] + "\n" + str[6:] print(str)
12th Aug 2016, 6:48 AM
‫Ido Tal
‫Ido Tal - avatar
+ 1
insert \n where you want to split d="hello world" dl = list(d) dl.insert(6,"\n") d=''.join(dl) print(d)
11th Aug 2016, 12:01 PM
‫Ido Tal
‫Ido Tal - avatar
+ 1
str = "go split" str = str[:3] + "\n" + str[3:] print(str)
12th Aug 2016, 6:14 AM
‫Ido Tal
‫Ido Tal - avatar
+ 1
print("hello \n world")
12th Aug 2016, 12:10 PM
minakshi singh
minakshi singh - avatar
0
Will try this out. But is this the only way?
12th Aug 2016, 6:04 AM
Sandeep Sreenivasanunni
Sandeep Sreenivasanunni - avatar
0
thanks that worked.
12th Aug 2016, 6:18 AM
Sandeep Sreenivasanunni
Sandeep Sreenivasanunni - avatar
0
can u explain dat:3 and 3: means?
12th Aug 2016, 6:24 AM
Sandeep Sreenivasanunni
Sandeep Sreenivasanunni - avatar
0
what if i have three words n split them in three different lines. how will it work? i mean:3 &3: wont work.
12th Aug 2016, 6:43 AM
Sandeep Sreenivasanunni
Sandeep Sreenivasanunni - avatar
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.
12th Aug 2016, 12:17 PM
‫Ido Tal
‫Ido Tal - avatar