kiki2005 (5)

This piece of code keeps giving me the error "character " not defined and I don't understand what to do with it.Could someone please check through what I have done so far on the code and check for any mistakes.

You are viewing a single comment. View All
EchoCoding (252)

You don't need the global keyword. In Python, globals are only needed if a variable is declared within a function. Simply remove the global keyword and the code will run as expected.

Besides that, you haven't called the function menu.

This should work:

print("Welcome to Password Checker")
def menu():
  print("Please enter a number that fits with one of the below.")
  print("1: Password Checker")
  print("2: Password Generator")
  print("3: Quit")
  menuSelection = int(input("..."))

  character = 0

  if menuSelection == 1:
    password = input("please enter a password")
    if password != "":
      if character <= 8:
        print ("this password is too short")
      if character >= 24:
        print("this password is too long")
      if character >= 9 and character <= 23:
        character = character + 1
        point = 0 
        length = len(password)
        uppers = [x for x in password if x.isupper()] 
        uppernum = len(uppers) 
        lowers = [x for x in password if x.islower()] 
        lowernum = len(lowers)
        point = point + length + (uppernum * 5) + (lowernum * 5)
  elif menuSelection == 2:
    print("lets generate!") # create the generator here
  elif menuSelection == 3: