Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In python plz 1. Write a function lookup name0 that takes as a parameter a string representing the name of a file. Each line of

image text in transcribed

In python plz

image text in transcribed

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 /Users/bmaya/Documents/DePaul Teaching/17-18_WQcsc241W2017Hws/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 File Edit Shel 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: Taci The corresponding name is 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: ill The corresponding name is W1111am Enter a nickname >lookup name'none.txt') none.txt could not be opened. Exiting

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional IPhone And IPad Database Application Programming

Authors: Patrick Alessi

1st Edition

0470636173, 978-0470636176

More Books

Students also viewed these Databases questions

Question

Discuss the five contemporary communication issues facing managers.

Answered: 1 week ago