Question: 1 . Copy step _ 1 . py to step _ 2 . py to use as a starting point. 2 . Store the name
Copy steppy to steppy to use as a starting point.
Store the name of the text file in a variable.
Use a tryexceptelse block to open the file.
If a FileNotFoundError exception is thrown, display a message to the user indicating that the file could not be found and quit the program with the quit function. If this happens, it's either because the text file is not in the same folder as your program file or there's a spelling error in the file name.
In the else block, which we only get to if we have successfully opened the file:
Read and discard the first line of the file using readline This is the column heading line and we don't need it
In a for loop, read each line of the file and strip the trailing line break. Split the line using the split method and a tab as the delimiter, t
The split should return three fields, which are the values for the timestamp, the name and the comment.
Create a dictionary with keys of "date", "name" and "timestamp" and use the values provided by the strip call.
Append the dictionary to the records list.
Test your program.
First choose Menu Selection You should see each record from the file displayed.
Choose Menu Selection and add another entry.
Choose Menu Selection again and you should see the original records, along with the one you have added.
Note that if you run the program again, none of the new records you entered via Menu Selection will show because we haven't updated the text file. That's part of the final step.
If everything goes as planned, take a bow! Well done!
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
