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 stringfun.py that does the following: Asks the user to input a string. Saves a file called "finalexam.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@SherdilsMacBookPro cscifalabfinal python stringfun.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 finalexam.txt to the same folder as stringfun.py: apple appl app ap a You can also view this example file yourself: I've saved it as finalexamexample.txt in this folder. NOTE: You need to match this file format exactly for the autograder to work. Don't put a period or anything else like that after each line. Hint : You probably want to take a look at string slicing from Lecture You also probably should be using some kind of for loop in your solution. Hint : 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: mystring "apple" numletters lenmystring printnumletters
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
