Jul-12-2020, 06:53 PM
Thanks for the response. I have just read the basic theory on dictionary and this is the first time I am trying to program using dictionaries. In particular, I don’t know the following:
** How to read from a file and store key value pair in dictionary.
** How to check a dictionary entry and update it if it isn’t updated.
My plan to approach the problem is simple.
1. Read the first set of key value pair.
2. Check if the value is a numeral. If yes, then store it as the first element of the dictionary.
3. Then, read the next pair of key value pair. Check if the value is a numeral.
4. If the key doesn’t exist, make a new key value pair entry. Otherwise update the value field.
5. Repeat steps 3 and 4 till there are no more entries in the given file.
Since this is the first time I am working on python and with dictionary feature, I am unable to execute the code. I hope you will be able to help me.
Thanks and Regards,
Arvind Gupta.
** How to read from a file and store key value pair in dictionary.
** How to check a dictionary entry and update it if it isn’t updated.
My plan to approach the problem is simple.
1. Read the first set of key value pair.
2. Check if the value is a numeral. If yes, then store it as the first element of the dictionary.
3. Then, read the next pair of key value pair. Check if the value is a numeral.
4. If the key doesn’t exist, make a new key value pair entry. Otherwise update the value field.
5. Repeat steps 3 and 4 till there are no more entries in the given file.
Since this is the first time I am working on python and with dictionary feature, I am unable to execute the code. I hope you will be able to help me.
Thanks and Regards,
Arvind Gupta.