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
YatinBayya (18)

At the top of your code, it should look like this

global character 

It is because of that character only exists in the menu function therefore if you take it outside the function and make it global it can be used anywhere in your application.

Hope that helps :)

YatinBayya (18)

If that does help click the check mark next to my answer.

kiki2005 (5)

@YatinBayya I put it in before all the code but it said invalid syntax.What should i do now?

YatinBayya (18)

@kiki2005 then you have some minor errors but I fixed it for you... I recommend to compare and contrast both and implement better syntax next time

global character
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("..."))
    if menuSelection == 1:
        password = input("please enter a password")
        for c in password :
            if c.isspace() != True:
              character = character + 1
if character<=8:
       print ("this password is too short")
if character>=24:
       print("this password is too long")
  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)