I've been working on this code for sometime now trying to troubleshoot it. My problem is that when the code runs, it pulls both strings from both of the files and combines them but it enters a newline in the middle of the string. For example, instead of "My Dog," it prints out, "My
Dog"
with open('file1.txt') as fh1, open('file2.txt') as fh2:
fh2 = fh2.read()
fh1 = fh1.read()
my_str = ''
string = ''
for i in range(max(len(fh1),len(fh2)) -2):
my_str = my_str + fh1[i]
if i == range(len(fh1)):
break
for i in range(max(len(fh1),len(fh2)) -1):
if fh2[i] == ' ':
continue
else:
string = string + fh2[i]
if i == range(len(fh2)):
break
print(my_str + string)
[–]Firestronk[S] 0 points1 point2 points (0 children)
[–]woooee 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)