Question: In Python please! I included a screenshot of the text file that is needed for this problem. The screenshot is titled capitals.txt. Thanks! Activity 1:
In Python please! I included a screenshot of the text file that is needed for this problem. The screenshot is titled capitals.txt. Thanks!

Activity 1: For this problem, you will need the text file called capitals.txt that contains data about state capitals. Each line of the file contains two fields of tab-delineated information. The first field is the name of the state. The second field is the name of the capital. Read this data into a dictionary. The key should be the state and the value will be the capital. Write a program that will continually request from the user the name of a capital they wish to delete. Your program will then remove that capital from the dictionary if it is in the dictionary. Inform the user that the capital was deleted, or if the capital is not there, inform the user that it was not a capital. You then need to ask the user if they wish to remove any more capitals. In the below examples, the underlined content represents the user's input. You need to format your program as the example below. When the user informs you they are done, then write out the dictionary to a new file called nonDeletedCaps.txt in the same tab-delineated form as the input file. Enter a state capital to delete: Dover Capital deleted. Do you want to delete another state capital (Y or N): Y Enter a capital to delete: Dover Not a state capital. Do you want to delete another state capital (Y or N): Y Enter a state capital to delete: Chicago Not a state capital. Do you want to delete another state capital (Y or N): Y Enter a state capital to delete: Topeka Capital deleted. Do you want to delete another state capital (Y or N):N If you are using the example above, your output file will not have either of the following lines in it: Delaware Kansas Dover Topeka Activity 1: For this problem, you will need the text file called capitals.txt that contains data about state capitals. Each line of the file contains two fields of tab-delineated information. The first field is the name of the state. The second field is the name of the capital. Read this data into a dictionary. The key should be the state and the value will be the capital. Write a program that will continually request from the user the name of a capital they wish to delete. Your program will then remove that capital from the dictionary if it is in the dictionary. Inform the user that the capital was deleted, or if the capital is not there, inform the user that it was not a capital. You then need to ask the user if they wish to remove any more capitals. In the below examples, the underlined content represents the user's input. You need to format your program as the example below. When the user informs you they are done, then write out the dictionary to a new file called nonDeletedCaps.txt in the same tab-delineated form as the input file. Enter a state capital to delete: Dover Capital deleted. Do you want to delete another state capital (Y or N): Y Enter a capital to delete: Dover Not a state capital. Do you want to delete another state capital (Y or N): Y Enter a state capital to delete: Chicago Not a state capital. Do you want to delete another state capital (Y or N): Y Enter a state capital to delete: Topeka Capital deleted. Do you want to delete another state capital (Y or N):N If you are using the example above, your output file will not have either of the following lines in it: Delaware Kansas Dover Topeka
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
