I function to display computer pioneers name def DisplayNames (name Dict) print \nComputer Pioneers name list: ') for name in nameDict print (name) main method def main () open ( Pioneers.txt'); inputFile nameDict = ) ; singleLine while singleLine: splittedLine inputFile.readline singleLine.split(','); nameDict [splittedLine [0]] = splittedLine [1]; = inputFile.readline ) singleLine inputName = while (True) DisplayNames (nameDict); = input ('\nEnter a name from the above 1list (Enter Quit to exit) '); inputName def close (inputName) if inputName.upper () "QUIT": exit from the program after the result print ("Thank you. ") quit elif inputName in nameDict.keys ) print (inputName ',' nameDict [inputName]); #otherwise name doesn't exist. Ask user to try again else: print 'Entered name is not found in the list. Please try again with different name.'); main (
Python 3.7.4:
I have project named “MOREPioneers.py “. I need to take a text file named Pioneers.txt that has a list of computer influencers and their accomplishments separated by a comma and display them when the user requests. It SHOULD be able to accept mixed cases for the name, loop as many times as the user wants, and end when the user says “Quit,” without using “break;” my instructor says that using “break” is a bad practice. I seem to be failing on all accounts, ha. Would you mind reviewing my code and telling me how I can correct it, please?
The code is below for you to copy and paste, I've also attached a picture in case the indentation gets lost:
''' function to display computer pioneers name '''
def DisplayNames(nameDict):
print('\nComputer Pioneers name list: ');
for name in nameDict:
print(name);
''' main method '''
def main():
inputFile = open('Pioneers.txt');
nameDict = {};
singleLine = inputFile.readline();
while singleLine:
splittedLine = singleLine.split(',');
nameDict[splittedLine[0]] = splittedLine[1];
singleLine = inputFile.readline();
inputName = '';
while(True):
DisplayNames(nameDict);
inputName = input('\nEnter a name from the above list (Enter Quit to exit): ');
def close(inputName): # exit from the program after the result
if inputName.upper() = "QUIT":
print("Thank you.")
quit()
elif inputName in nameDict.keys():
print(inputName + ',' + nameDict[inputName]);
# otherwise name doesn't exist. Ask user to try again.
else:
print('Entered name is not found in the list. Please try again with different name.');
main()
![I function to display computer pioneers name
def DisplayNames (name Dict)
print \nComputer Pioneers name list: ')
for name in nameDict
print (name)
main method
def main ()
open ( Pioneers.txt');
inputFile
nameDict = ) ;
singleLine
while singleLine:
splittedLine
inputFile.readline
singleLine.split(',');
nameDict [splittedLine [0]] = splittedLine [1];
= inputFile.readline )
singleLine
inputName =
while (True)
DisplayNames (nameDict);
= input ('\nEnter a name from the above 1list (Enter Quit to exit) ');
inputName
def close (inputName)
if inputName.upper () "QUIT":
exit from the program after the result
print ("Thank you. ")
quit
elif inputName in nameDict.keys )
print (inputName ',' nameDict [inputName]);
#otherwise name doesn't exist. Ask user to try again
else:
print 'Entered name is not found in the list. Please try again with different name.');
main (](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fa7d4e176-0bde-4ba1-878b-9d1deee7d221%2Fcd57dc97-3d61-4525-b925-c6ef803a2d69%2Ffxt9i1s.jpeg&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)