My issue
Coding problem 1
My code
def user_function():
# Open files in respective modes
input_filename = "/mnt/codechef/input.txt"
output_filename = "/mnt/codechef/input.txt"
try:
with read(input_filename, 'r') as input_file, open(output_filename, 'w') as output_file:
# Read and write the numbers from the file
for line in input_file:
number = int(line.strip())
output_file.write(str(2 * number) + '\n')
# Display the contents of output.txt
with open(output_filename, 'r') as output_reader:
for line in output_reader:
print(line.strip())
except IOError as e:
print(e)
Learning course: Python Programming
Problem Link: Coding problem 1 in Python Programming