Question

Write a program that inputs a string from the user representing a password, and checks its...

Write a program that inputs a string from the user representing a password, and checks its validity. A valid password must contain:

-At least 1 lowercase letter (between 'a' and 'z') and 1 uppercase letter (between 'A' and 'Z').

-At least 1 digit (between '0' and '9' and not between 0 and 9). At least 1 special character (hint: use an else to count all the characters that are not letters or digits).

-A minimum length 6 characters.

-No spaces (hint: when you encounter a space, you can break out of the loop).

The program should output a message saying that the password is valid, or if it isn't valid, saying why not. For example, if the password has a length of 5, the output should say "The password is too short; a minimum of 6 characters required" and so on.

I need help with this ex please (python 3.6 )

0 0
Add a comment Improve this question Transcribed image text
Answer #1
password = input("Enter password: ")
l = len(password)
space = False
lower = False
number = False
if (l<6):
    print('The password is too short; a minimum of 6 characters required')
else:
    for x in password:
        if x.islower():
            lower = True
        if x.isnumeric():
            number = True
        if x==' ':
            space = True
        break
    if (space == True):
        print("Space found in the password")
    elif(lower==False):
        print("No lower cases letter found in the password")
    elif (number == False):
        print("No digit found in the password")
    else:
        print("Password is valid")

Add a comment
Know the answer?
Add Answer to:
Write a program that inputs a string from the user representing a password, and checks its...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Python Create a function that checks user input in an attempt to create a password. The...

    Python Create a function that checks user input in an attempt to create a password. The valid_password function accepts a password as an argument and returns either true or false to indicate whether the password is valid. A valid password must be at least 7 characters in length, have at least one uppercase letter, one lowercase letter, and one digit. Respond with output to the user as to whether the password is valid or not, and allow the user to...

  • Write a program that asks the user to enter a password, and then checks it for...

    Write a program that asks the user to enter a password, and then checks it for a few different requirements before approving it as secure and repeating the final password to the user. The program must re-prompt the user until they provide a password that satisfies all of the conditions. It must also tell the user each of the conditions they failed, and how to fix it. If there is more than one thing wrong (e.g., no lowercase, and longer...

  • in C++, Design a program that asks the user to enter a password, and then analyze...

    in C++, Design a program that asks the user to enter a password, and then analyze the password, and then analyze the password for the following weaknesses: 1. Fewer than 8 characters 2. Does not contain at least one uppercase letter and one lowercase latter 3. Does not contain at least one numeric digit 4. Does not contain at least one special character( a character that is not a letter or numeric digit) 5. Is a sequence of consecutive uppercase...

  • In python Exercise 4 (graded) Write a function "passValidate" that takes a string "s" and checks...

    In python Exercise 4 (graded) Write a function "passValidate" that takes a string "s" and checks the validity of string as a password Validation Rules: At least 1 lowercase letter between [a-z] and 1 upper case letter between [A-Z]. At least 1 number between [0-9 At least 1 character from [$#@]. Minimum length 6 characters. Maximum length 16 characters. CS103-Lab 13 Page 3 of 3 Sample Input: s"Uab@2762" Sample Output: True

  • 4: A certain computer program is accessed by entering a user-defined password. If the password a. can contain any lo...

    4: A certain computer program is accessed by entering a user-defined password. If the password a. can contain any lowercase letter, uppercase letter, or digit from 0-9, and must contain 10 characters, how many possible passwords are there if no character can be used more than once? Express your answer as a factorial statement. Is 8 an example of permutations or combinations? b. 4: A certain computer program is accessed by entering a user-defined password. If the password a. can...

  • Please make this Python code execute properly. User needs to create a password with at least...

    Please make this Python code execute properly. User needs to create a password with at least one digit, one uppercase, one lowercase, one symbol (see code), and the password has to be atleast 8 characters long. try1me is the example I used, but I couldn't get the program to execute properly. PLEASE INDENT PROPERLY. def policy(password): digit = 0 upper = 0 lower = 0 symbol = 0 length = 0 for i in range(0, len(password)): if password[i].isdigit(): # checks...

  • Design a Java program to reset a user's password. The password must consist of exactly six...

    Design a Java program to reset a user's password. The password must consist of exactly six characters, of which one must be a digit, one must be an uppercase letter, and one must be a lowercase letter. Tell the user if the password is correct or if incorrect tell them what is wrong with it. For example, you could say: "Not valid! the password must have 6 characters! Goodbye!" Can't contain loops. Using Boolean, String, Int, char

  • Design and implement a Java program (name it PasswordTest) that accepts a string from the user...

    Design and implement a Java program (name it PasswordTest) that accepts a string from the user and evaluates it as a password, giving it a valid or invalid verdict A good password will be at least 8 characters and includes at least one lower-case letter, at least one upper-case letter, at least one digit, and at least one character that is neither a letter nor a digit. Your program will need to check each character in the string in order...

  • Write an LC-3 program (starting at memory location 0x3000) to take a string as input and...

    Write an LC-3 program (starting at memory location 0x3000) to take a string as input and then output information about this string. The end of the string will be denoted with the "#" character. Once the "#" has been found, output the following in order: 1) The letter “u” followed by the number of uppercase letters in the string (A-Z) 2) The letter “l” followed by the number of lowercase letters in the string (a-z) 3) The letter “n” followed...

  • 1. Write a C++ program called Password that handles encrypting a password. 2. The program must...

    1. Write a C++ program called Password that handles encrypting a password. 2. The program must perform encryption as follows: a. main method i. Ask the user for a password. ii. Sends the password to a boolean function called isValidPassword to check validity. 1. Returns true if password is at least 8 characters long 2. Returns false if it is not at least 8 characters long iii. If isValidPassword functions returns false 1. Print the following error message “The password...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT