Question: Write a program in string _ fun.py that does the following: Asks the user to input a string. Saves a file called final _ exam.txt

Write a program in string_fun.py that does the following: Asks the user to input a string. Saves a file called "final_exam.txt". The file should contain as many lines as the user string has letters. The first line should contain the full string the user entered. The second line should contain all letters of the user string except the last one. The third line should contain all characters except the last two. This pattern should continue until the final line of the file, which will just be the first letter of the original user string. I think it's easier to just show an example. Here's my example solution running: (base) sniyaz@Sherdils-MacBook-Pro csci-110-fa24-lab-final % python3 string_fun.py Enter a string: apple In this case, the user enters the string apple. Note that the Python program itself does not output anything to the terminal. It does, however, save this file (final_exam.txt) to the same folder as string_fun.py: apple appl app ap a You can also view this example file yourself: I've saved it as final_exam_example.txt in this folder. NOTE: You need to match this file format exactly for the auto-grader to work. Don't put a period or anything else like that after each line. Hint 1: You probably want to take a look at string slicing from Lecture 12. You also probably should be using some kind of for loop in your solution. Hint 2: Remember: you can use the len() function to return the number of letters in a string (the same way you would call it on a list to get the length of that list). See this example in the Python interpreter: >>> my_string = "apple" >>> num_letters = len(my_string)>>> print(num_letters)5

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 Programming Questions!