Question: lines 1 to 3: #Write a function called write_weird_file. write_weird_file #should take two positional parameters. The first should be #a filename, and the second should

lines 1 to 3: #Write a function called write_weird_file. write_weird_file #should takelines 1 to 3: #Write a function called write_weird_file. write_weird_file #should take two positional parameters. The first should be #a filename, and the second should be a list. The function

file input/output help

FlexibleFileWriting.py SubmitRun Grades Reset 3 #a filename, and the second should be a list. The function Console output will be displayed here 4 #should also have three keyword parameters: mode, sort-first 5 #and reverse-first. The default value for mode should be "w", 6 #and the default values for both sortfirst and reversefirst - - 7 #should be False 8# 9 #write weird file should write the contents of the list to 10 #the given filename. Each item from the list should be on a 11 #separate line. The list items could be strings, floats, 12 #characters, or integers. If the mode is "w", it should 13 #overwrite the current contents; if the mode is "a", it 14 #should append to the current contents. You may assume there 15 #will be no other value for mode 16 # 17 #If sort first is True, it should sort the list before 18 #writing-If reverse first is True, then it should reverse 19 #the list before writing. If both are True, it should sort, 20 #then reverse 23 #Add your function here! 27 #Below are some lines of code that will test your function 28 #You can change the value of the variable(s) to test your 29 #function with different inputs 30# 31 #If yo 32 #print nothing. However, if you open the file called 33 #output.txt in the top left after running it, the contents 34 #of the file should be: 35 #wait, where'd the other text go? 36 #It's gone! 37 #3 38 #2 39 #1 40 write weird file("output.txt", ["Hmm, I bet this text will disappear.", "I wonder where it will go?"]) 41 write _weird file("output.txt", "Wait, where'd the other text go?", "It's gone! ur function works correctly, this will originally 42 write _wird fileoutput.txt", 2, 1, 3], mode-", sort first-True, ree st-True) 43

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!