In dictionary, key contains certain characters

Asked 2 years ago, Updated 2 years ago, 74 views

How should I write a code that outputs a key containing a specific character out of all keys in the dictionary and outputs all data types included in the value?

dictionary python

2022-09-22 18:01

2 Answers

If you output a specific key in a dictionary and a data type of its value,

dics = [..... ]

for i in dics:

    ifi == specific key:
        print(i, type(dics[i])) 


2022-09-22 18:01

dics = {"1":"people"",2":"not people"",3":"people"}
for i in dics.keys:
    ifi == specific string or numeric string:
        print(i,dics.get(i))

That's how it'll work.

It's a dictionary, so I made it a dictionary.

But they didn't tell me the conditions, so I just did it as I intended.


2022-09-22 18:01

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.