Python Forum
Dictionary based exercise
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dictionary based exercise
#3
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.
Reply


Messages In This Thread
Dictionary based exercise - by garvind25 - Jul-11-2020, 06:28 PM
RE: Dictionary based exercise - by ndc85430 - Jul-11-2020, 06:54 PM
RE: Dictionary based exercise - by garvind25 - Jul-12-2020, 06:53 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Dictionary lookups exercise (PyBite #109) Drone4four 14 6,304 Aug-10-2020, 06:41 PM
Last Post: Intr0spective
  Dictionary based assignment: Need help RoyceJ 6 4,052 Aug-29-2018, 05:30 AM
Last Post: perfringo
  logic comparater based on dictionary values ijosefson 3 3,359 Oct-16-2017, 06:04 AM
Last Post: Mekire

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020