I'm trying to do this assignment:
This is what I have and I am getting a syntax error on >
Pasted code:
# Specify where the input and output file is
InputFile = open('C:\Python\unsorted_fruits.txt', 'r')
OutputFile = open('C:\Python\sorted_fruits.txt', 'w')
# Read the input file
Fruits = InputFile.readlines()
# Sort the items in the list
Fruits.sort()
# Remove the blank lines and write the file
for fruit in Fruits:
if fruit <>"\n": # if fruit is blank, skip the write
OutputFile.write(fruit) # otherwise write the fruit to the output file
# Close the input and output file
InputFile.close()
OutputFile.close()