Day 71 - solution help

Can someone help me understand why this code doesn’t work. I know it has to do with the login() subroutine, but I’ve been fiddling with it for too long and still stuck. The error produced isn’t legible to me. Thanks in advance.

from replit import db
import random

def adduser():
  username = input("Username: ")
  password = input("Password: ")
  salt = random.randint(1,9999)
  newpassword = f"{password}{salt}"
  newpassword = hash(newpassword)
  db[username] = {"password": newpassword, "salt": salt}

def login():
  username = input("Username: ")
  pw = input("Password: ")
  salt = db[username]["salt"]
  newpw = f"{pw}{salt}"
  keys = db.keys() 
  for key in keys: 
    if key in keys:
      if newpw == db["password"]:
        print("Login Successful!")
        print("Password incorrect")
      print("Username incorrect")
while True:
  menu = input("1. Add user\n2. Login\n> ")
  if menu == "1":

A post was merged into an existing topic: Day 071 - Project 71 : Hashing passwords