Posted on 19th April 2024
You can use in operator to check if an item is in a dictionary let me explain it to you by a simple example:
def main():
months={
‘Jan’ = 1,
‘March’ = 2,
‘June’ = 3
}
#checking for Jan
if ‘Jan’ in months:
print(months[‘Jan’])
if _name_ == ‘_main_’:
main()
Output:
1
STILL GOT QUERIES?