Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

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

Data Access Patterns Database Interactions In Object Oriented Applications

Authors: Clifton Nock

1st Edition

0321555627, 978-0321555625

More Books

Students also viewed these Databases questions

Question

What are the guidelines for determining and using affirmations?

Answered: 1 week ago