Answered step by step
Verified Expert Solution
Question
1 Approved Answer
in python plz, screenshot of code helps with figuring out indentations 1. Write a function lookup name0 that takes as a parameter a string representing
in python plz, screenshot of code helps with figuring out indentations
1. Write a function lookup name0 that takes as a parameter a string representing the name of a file. Each line of the file contains a name followed by some amount of whitespace followed by a nickname for that name. The function reads the names and associated nicknames from the file, and repeatedly allows the user to enter a Teaching/17-18 WO/esc241W2017Hws/assign8 html 1/4 0/2018 Assignment 8-CSC 241-801 nickname, printing the corresponding name in response. If the nickname is not in the file the function prints Not Found in response to that query. The function stops when the user enters the empty string For full credit the function must create a dictionary to store the names and associated nicknames. You can find an example file nicknames.txt in the zip file for the assignment. You may not assume that the file the function is given contains any names or nicknames in particular, but you may assume that the file does not have any duplicate names or nicknames. You should also assume that each line of the file consists of a single name and nickname pair. If the function cannot open the file provided as a parameter it should print a message to that effect and stop Python 3.62 Shell Eile Edit Shell Debug Options Window Help >lookup name ('nicknames.txt) Enter a nickname: Pru The corresponding name is Prudence. Enter a nickname: Trudy The corresponding name is Gertrude. Enter a nickname: Yaci The corresponding name 13 Yanacey. Enter a nickname: Alex The corresponding name is Alejandro Enter a nickname: Bri The corresponding name is Brianna. Enter a nickname: Isabella Not Found Enter a nickname: Cooks Not Found Enter a nickname: Vill The corresponding name is wi11iam. Enter a nickname: lookup name (' none.txt) none.txt could not be opened. Exiting .. . In python plz nicknames-Notepad File Edit Format View Help Prudence PruGertrude TrudyYanacey YaciAlejandro AlexBrianna BriWilliam WillStep 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