Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 280
  • Last Modified:

Storing dictionary values


Hi,

This question relates to my previous question:
http://www.experts-exchange.com/Programming/Programming_Languages/Python/Q_21902718.html?qid=21902718

I now can store the values of the model attributes from all vehicle tags in my XML file in a list.

For each model value in the list, I need to find the coresponding country (stored in a dictionary) and put this into a new country list.

Please excuse my lack of Python skills, but I am picking it up.
What I have is this:

factoryloc = {"toyota":"japan", "fiat":"italy", "renault":"france", "chevrolet":"united states"}

vehicleLst = xmldoc.getElementsByTagName("vehicle")

myCarPark = []
for vehicle in vehicleLst:
      myCarPark.append(vehicle.getAttribute('make'))


carCountries = []

i = 0
for car in myCarPark:
    factoryloc["car[0]"] = place  ##I realise that this is wrong, but hopefully you will get the idea
    carCountries.append(place)


I know where I'm going wrong, but can't quite figure out how to link the list to the dictionary.


Thanks,
John
0
JohnAutoSales
Asked:
JohnAutoSales
1 Solution
 
ramromconsultant Commented:
I think you want place = factoryloc[car].
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now