title: How to check a specific value for a key in python
body: <p>I am developing a basic registration and login code for a school project. I have created a dict which has some keys and values as usernames and passwords but when entering a password of a different username to another username, the code validates and continues. I want the code to check the value for the specific username and validate it.</p>
  <p>I am just a beginner and this just a rough code of my project.</p>
  <pre><code>fa='Y'
  while fa=='y' or fa=='Y':
      user_name=input(&quot;Enter Username : &quot;)
      password=input(&quot;Enter Password : &quot;)
      if user_name in up.keys():
          if password in up.values():
              print(&quot;Valid Username and Password.Login Completed&quot;)
          else:
              print(&quot;Invalid Password for the Usename. Login Failed&quot;)
      else:
          print('Invalid Username. Register to Login ')
      fa=input(&quot;Login Again (Y) :&quot;)
  print(up)
  </code></pre>