0

I want to check that the two user's inputs exist in the dict together as a key value pair togehter; for example:

dict = {"ABC" : 123, "DEF" : 456}
firstInput= input("Please enter your age: ")
secondInput= input("Please enter your name: ")

Then: If the user's inputs are "ABC" and 123, respectively, or "DEF" and 456, it will return some value and another if not.

Gerd
  • 2,568
  • 1
  • 7
  • 20

1 Answers1

0

I’m tempted not to give a code example, as it seems like this question could be answered with a simple Google search. That being said, something like this:

try:
    value = dict[firstInput]
except KeyError:
    value = 'No entry for {}'.format(firstInput)

if value == secondInput:
    # success 
else:
    return 'Entry found but incorrect value supplied'
Jon Behnken
  • 560
  • 1
  • 3
  • 14