The following is my dictionary. How can I check if a given value is in the dictionary. For example, if user enter a number 129, then, how do I check if the number exist in either key A
or B
?
studentData = {
'A': [127, 104],
'B': [128, 204, 205, 118]
}
if studID <= 0 :
print ('Invalid id. Student id must be positive')
studID = int(input('Enter student id: '))
elif studID in studentData.values() == True: # how to check if input exist?
print (f'fail')
else:
studentData[modCode].append(int(studID))
print ("complete")
break