Linked Questions

Popular Questions

How to switch the order of text in a line?

Asked by At

I have a text file with lines going like this: text1:numbers:text2. How do I separate these so that I can output for example text1:text2:numbers to another file?

file1=open("textfile.txt","r")

file2=open("textfile2.txt","w") 

while True:

    line=file1.readline()

    a=line.split(":")

    if line=="":break

Related Questions