How do I create a dictionary from two parallel strings?

Viewed 8126

I have two text files, which are formatted like so:

foo,bar,etc

the other one is like this:

1,2,3

and I want to put these two text files into one dictionary for Python without having to do each one by hand. I want the output to connect the strings to the numbers. Is there any way of doing this?

4 Answers

I'm just starting out, but it might be more simple to just run the two together in a single line:

string_dict = {'etc': '3', 'foo': '1', 'bar': '2'}
Related