My goal for this code is to prompt a user for company, city, and state. After I print the data, I need to remove the city and then print the new data. When I run this code, it prints out the same data twice, basically not removing the city. Please help me understand when I split cityState why it's not then allowing me to remove the city.
Thanks for your help!
#Create a dictionary
user_data = {}
#Prompt for user data
company_name = input("Enter company name: ")
cityState = input("Enter company city and state: ")
#store the responses
user_data[company_name] = cityState
#print data
print("\nCompany details:")
for company_name, cityState in user_data.items():
print(company_name + " " + cityState)
#split the data
temp = cityState.split()
user_data[temp[0]] = temp[1]
#remove the city
user_data.pop(temp[0])
#print the data
print("\nWith the city removed: ")
print(company_name + " " + cityState)