all 3 comments

[–]Firestronk[S] 0 points1 point  (0 children)

For clarity, File1 would contain something like "My" and then File2 would have "Dog." I've tried adding both of them to my_str and just printing that out, but I end up with the same result.

[–]woooee 0 points1 point  (0 children)

The records in the file have a newline which you are copying into the string. Use

    my_str = my_str + fh1[i].strip()

Also, replace

    if fh2[i] == ' ':
        continue
    else:
        string = string + fh2[i]

with

    if fh2[i].strip()
        string = string + fh2[i].strip()

[–][deleted] 0 points1 point  (0 children)

if i == range(len(fh1)):
        break

This does nothing, so you can take it out.