Question: Task 1: Write a Python program that takes as input from the user the name of a file containing postcode/location information. Each line in the

 Task 1: Write a Python program that takes as input from

Task 1: Write a Python program that takes as input from the user the name of a file containing postcode/location information. Each line in the file consists of the postcode followed by a tab followed by a comma-separated list of locations that have that postcode. For example, the file postcode.txt contains: LE1 LE2 LE3 LE4 LE5 Leicester Oadby,Knighton,Highfields, Aylestone Braunstone, Glenfield, Groby Road Beaumont Leys, Belgrave,Birstall, Thurmaston Hamilton, Thurnby Lodge, Evington Your program should create a list of postcode/location pairs with each pair stored in the list. It should print the list, so that you can check that your program has performed correctly. Please enter the file name: postcode.txt [['LET', ['Leicester']], ['LE2', ['Oadby', 'Knighton', 'Highfields', 'Aylestone']], ['LE3', ['Braunstone', 'Glenfield', 'Groby Road']], ['LE4', ['Beaumont Leys', 'Belgrave', 'Birstall', 'Thurmaston']], ['LE5', ['Hamilton', 'Thurnby Lodge', 'Evington']]] Note: You will need to use split twice: first to separate the postcode from the rest of the string and secondly to separate the rest of the strings into individual locations

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!