with python do whis: Edit or delete a user profile When the user chooses 2, the first thing that it should do is to check whether the user information is loaded in the program (i.e., check if the user information is passed to the function that generates recipe recommendations). If the user information is passed to the function (i.e., the user chose option 1 before choosing option 2), the program should show the user the following menu: Hello (user name) You can perform one of the following operations: 1) Delete your profile 2) Edit your profile a. If the user chooses 1, perform the following subtasks to delete a user profile: 1- Search for the user profile in the file userInformation.txt using the user name in read mode; once you find the user profile (i.e., the line that contains all the user information), pass it to a function that deletes the user information. 2- The function should create a
with python do whis:
Edit or delete a user profile
When the user chooses 2, the first thing that it should do is to check whether the user information is loaded in the
Hello (user name)
You can perform one of the following operations:
1) Delete your profile
2) Edit your profile
a. If the user chooses 1, perform the following subtasks to delete a user profile:
1- Search for the user profile in the file userInformation.txt using the user name in read mode; once you find the user profile (i.e., the line that contains all the user information), pass it to a function that deletes the user information.
2- The function should create a temporary file called temp.txt in write mode and search the file userInformation.txt in read mode for the user that you want to delete (the user returned by the previous step). Write all the content of the file userInformation.txt in the file temp.txt so long as the user is not there, in other words, do not write (delete) the user. The end of this process should yield a file called temp.txt that does not include the user.
3- Use the os module to delete the file userInformation.txt, then use it to rename the file temp.txt as userInformation.txt.
4- Print to the user a message stating that the record was deleted successfully.
5- If the file userInformation.txt contains just one user profile and you chose to delete this user, delete the file.
6- Make sure you also delete or clear the contents of the variable userInf
Step by step
Solved in 2 steps with 3 images