I'd like to investigate if there is a specific key like the title. I made my own code. I'd appreciate it if you could teach me a better way.
if 'key1' in dict.keys():
print "There is"
else:
print "None"
You don't have to bring a key from the dictionary.
if 'key1' in dict:
You can use this much.
Or
dict.has_key('key1')
You can also check 'key1'.
You used in
to check the key in dict
so you wrote it well.
© 2024 OneMinuteCode. All rights reserved.