-1

I'm working with a dictionary that's made up of multiple dictionaries:

my_dictt = {0: {'n': 1, 's': 5, 'w': 7, 'e': 3}, 7: {'w': 8, 'e': 0}, 8: {'e': 7}, 1: {'n': 2, 's': 0}, 2: {'s': 1}, 5: {'n': 0, 's': 6}, 6: {'n': 5}, 3: {'w': 0, 'e': 4}, 4: {'w': 3}}

I need to check if any values within any of the nested values is "?", but haven't been able to do so. I tried looping through the dictionary and using the dict.values() function, but have not gotten that to work so far. Does anyone know how I can get this done?

EHM
  • 877
  • 1
  • 7
  • 28
Damon
  • 11
  • 2

1 Answers1

0

I don't know if this is exactly what you are looking for. Let me know in the comments.

my_dictt = {0: {'n': 1, 's': 5, 'w': 7, 'e': 3}, 7: {'w': 8, 'e': 0}, 8: {'e': 7}, 1: {'n': 2, 's': 0}, 2: {'s': 1}, 5: {'n': 0, 's': 6}, 6: {'n': 5}, 3: {'w': 0, 'e': 4}, 4: {'w': 3}}
#first go to each value of yor dictionary
for eachValue in my_dictt.values():
    #then in each value that are dictionaries get each value again
    for eachNestedValue in eachValue.values():
        # check if any of values are ?
        if eachNestedValue == "?":
            print(True)
EHM
  • 877
  • 1
  • 7
  • 28