Python File Writing Format Issue <p><strong>The Code</strong></p> <pre><code>def rainfallInInches(): file_object = open('rainfalls.txt') list_of_cities = [] list_of_rainfall_inches = [] for line in file_object: cut_up_line = line.split() city = cut_up_line[0] rainfall_mm = int(line[len(line) - 3:]) rainfall_inches = rainfall_mm / 25.4 list_of_cities.append(city) list_of_rainfall_inches.append(rainfall_inches) inch_index = 0 desired_file = open("rainfallInInches.txt", "w") for city in list_of_cities: desired_file.writelines(str((city, "{0:0.2f}".format(list_of_rainfall_inches[inch_index])))) inch_index += 1 desired_file.close() </code></pre> <p><strong>rainfalls.txt</strong></p> <blockquote> <pre><code>Manchester 37 Portsmouth 9 London 5 Southampton 12 Leeds 20 Cardiff 42 Birmingham 34 Edinburgh 26 Newcastle 11 </code></pre> </blockquote> <p><strong>rainfallInInches.txt</strong> This is the unwanted output</p> <blockquote> <p>('Manchester', '1.46')('Portsmouth', '0.35')('London', '0.20')('Southampton', '0.47')('Leeds', '0.79')('Cardiff', '1.65')('Birmingham', '1.34')('Edinburgh', '1.02')('Newcastle', '0.43')</p> </blockquote> <p>My program takes the data from 'rainfalls.txt' which has rainfall information in mm and converts the mm to inches then writes this new information into a new file 'rainfallInInches.txt'.</p> <p>I've gotten this far except I can't figure out how to format 'rainfallInInches.txt' to make it look like 'rainfalls.txt'.</p> <p>Bear in mind that I am a student, which you probably gathered by my hacky code.</p>