1

In checkpassword2() the program should subtract 5 points if the password has only one lowercase or uppercase letter, or numerals 0-9 or symbols. I don't need the exact way just hints on how to get there.

import random

string = 'abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!$%^&*()-_=+'

def mainmenu():

    print('1. Check Password.')
    print('2. Generate Password.')
    print('3. Quit.')
    choice = int(input('Choice:'))

    while True:
        try:
            if choice == 1 :
                checkpass1()
                break

            elif choice == 2 :
                generatepass()
                break

            elif choice == 3 :
                print('Bye')
                break

            else :
                print('Invalid Choice Please Enter Again')
                mainmenu()

        except ValueError:
            print('Please Enter A Value Between 1 & 3')


    exit


def checkpass1():

    global password

    print('Please Enter Your Password')
    password=input('Password:')
    length= str(len(password))

    if len(password) <8 or len(password) >24:
        print('you password should be between 8 and 24 characters, please input again')
        checkpass1()
    else:
        checkpass2()

    checkpass2()

def checkpass2():

    global password, score

    score = len(password)
    if re.search(r'[0-9]', password):
        score= score + 5
    if re.search(r'[A-Z]', password):
        score= score + 5
    if re.search(r'[0-9]', password):
        score= score + 5
    if re.search(r'[!$%^&*()-_=+]', password):
        score= score + 5
    if score is >15:
        score= score + 10

#menu start
mainmenu()
CDspace
  • 2,639
  • 18
  • 30
  • 36
Z.ALI
  • 11
  • 3

0 Answers0