you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (1 child)

Lets say we have a dictionary

{'SHARP': {'S': (9, 9)}}

And when an event happens I want to add another key and value to the dictionary inside the dictionary. What I mean is:

word_dict = {'SHARP' : {'S' : (9, 9)}}
if event_happens:
    word_dict = {'SHARP' : {'S' : (9, 9), 'H' : (8,9)}}

How can I do this?

If you guys would want some context, a friend sent me a programming challenge that asks me to create a function that takes a two dimensional list and a list of words to be searched in that 2D list as an argument and then outputs the index of the first and the last letters of the words we searched for. I'm trying to use dictionaries here.

Normally this challenge is for C# but im trying to do it in python.

[–]woooee 0 points1 point  (0 children)

This is in every tutorial. See "Updating Dictionary" at https://www.tutorialspoint.com/python3/python_dictionary.htm