Question
File Update: a List of Strings 1. Code a comment with the python program name, author and course. 2. Define readShoeFile() composed of statements to
1. Code a comment with the python program name, author and course.
2. Define readShoeFile() composed of statements to :
declare shoeList
with open \"shoe.txt\" for reading as shoeFile have
for shoe line in shoeFile, replace(' ' in each line), then
have shoesList append each line input, then return shoeList
3. Define printShoeList with parameter shoeList and is to contain a loop
for printing each shoe item and it's index value.
4. Define a function named writeShoeFile with the parameter shoeList.
Open \"shoe.txt\" for writing as shoeFile followed by a statement for shoe in
shoeList to repeatedly have shoeFile invoke write (shoe) as separate lines.
5. Define addShoe with parameter shoeList to include an input() for a shoe name
(e.g. Merrill), followed by having the shoeList append(shoe), invoke
writeShoeFile with parameter(shoeList), then print a confirmation message.
6. Define deleteShoe(shoeList) that has statements to: assign to an index a
shoe line number from user input, and assign to shoe item the value
returned by having shoeList \"pop\" that shoe line number, invoke
writeShoeFile (shoeList), and print a delete confirmation.
7. Define printMenu() to print a title line followed by menu items for:
Print Shoe List (p)
Add a Shoe (a)
Delete a Shoe (d)
Exit (x)
8. Define a main function with statements to:
assign to shoeList the value returned by invoking readShoeFile,
next invoke printMenu(),
then repeatedly:
assign a menu choice returned by input() followed by
a selection structure with tests for values:
'p' for printShoes (shoes),
'a' for addShoe(shoes),
'd' for deleteShoe(shoes), or
'x' exit
invoke main()
-------------------------------------------------------------
*shoe.txt (to be stored in the same folder as fileUpdate.py):
Adidas
Asics
Brooks
Keds
Larnmern
New Balance
OTU
Rockport
Ryka
Skechers
Slow Man
Under Armour
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started