Question: What would be a good pseudocode for this code? file = open('C:Python34unsorted_fruits.txt','r') outfile=open('C:Python34sorted_fruits.txt','w') #readlines return a list fruits=file.readlines() #list.sort() do an inline sort fruits.sort() #remove
What would be a good pseudocode for this code?
file = open('C:\Python34\unsorted_fruits.txt','r') outfile=open('C:\Python34\sorted_fruits.txt','w')
#readlines return a list fruits=file.readlines()
#list.sort() do an inline sort fruits.sort()
#remove the blank lines and write the file for fruit in fruits: if fruit != ' ': #if fruit is blank, skip the write outfile.write(fruits) #otherwise write the fruit to the output file outfile.write(" ") #close the input and output file file.close() outfile.close()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
