The code below just makes it have one letter/number per line then it forms a new line, but I would like to have the numbers on each line and only form a new line everywhere there is a comma.
Is there a way to do this?
Thanks!

def hyp(aFile, bFile):
    lista = []
    a = open(aFile, "r")    
    b = open(bFile, "w")
    line = a.readline()

    for line in a:
        words = line.split()
        lista.append(words)
        value = str(lista)


    trunk = map(lambda x: math.sqrt(float(x[0])**2 + float(x[1])**2), lista)
    trunk1 = str(trunk)

    for answer in trunk1:
        b.write("%s\n"%answer)
    
    
    a.close()
    b.close()

"\n" is the newline character, so you are appending a newline every time you write "answer", so remove it there and add a statement to b.write "\n" every time a comma is found (and it is not apparent from the code posted how you test for a comma). Note that you can use either "readline()" or "for line in a:" but not both.

Oh I see, thank you very much!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.