Hello, just find this website and feel it is great to learn Python here.
I have a question when I try to read data from file and compile a dictionary from the data. The data look like this,

1 1 A A 0
1 2 A B 1
1 3 A C 2
1 4 A D 3
1 5 A E 4
etc.

I want to make a dictionary which has keys like {'AA': 0, 'AB':0, 'AC':2, 'AD':3 etc.}, that is the third and fourth elements combined to be key and fifth element on each line become value. File is .txt file.

Thanks a lot!

Recommended Answers

All 3 Replies

Push (code) button and include what you tried to do. Include complete error message, if any.

Thanks for the reply. I am trying and think I have made some progress. will come back to post.

It works by extracted to a list and index from there. some posts here are really helpful.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.