1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
VARVARA [1.3K]
3 years ago
6

Write a function named enterNewPassword. This function takes no parameters. It prompts the user to enter a password until the en

tered password has between 8 and 15 characters, including at least one digit. Tell the user whenever a password fails one or both of these tests. The function enterNewPasswordshould return the new password.
Computers and Technology
1 answer:
zloy xaker [14]3 years ago
4 0

Answer:

def enterNewPassword():

 while True:

   password = input("Enter password: ")

   has_digit = False

   for i in password:

     if i.isdigit():

       has_digit = True

       break

   

   if not has_digit or (len(password) < 8 or len(password) > 15):

     if len(password) < 8 or len(password) > 15:

       print("The password length must be between 8 and 15!")

     if not has_digit:

       print("The password must include at least one digit!")

   else:

     return password

print(enterNewPassword())

Explanation:

*The code is in Python.

Create a function named enterNewPassword that takes no parameter

Create an indefinite while loop. Inside the loop, ask the user to enter the password. Initialize the has_digit as False, this will be used to check if password contains a digit or not. Create a for loop, that that iterates through the password, if one character is digit, set the has_digit as True and stop the loop (Use isdigit() to check if the character is digit or not).

After the for loop, check if has_digit is false or the length of the password is not between 8 and 15. If the length of the password is not between 8 and 15, print the error. If has_digit is false, again print the error.

Otherwise, password met the requirements and return the password

Call the enterNewPassword() function and print the result

You might be interested in
To execute sas code, you can click on which icon?
faltersainse [42]

To execute SAS code, an icon which you can click on is: e. running man.

<h3>What is SAS?</h3>

SAS is an abbreviation for Statistical Analysis System and it can be defined as a statistical software suite which was developed at North Carolina State University by SAS Institute for the following field of study:

  • Business intelligence
  • Criminal investigation
  • Data management
  • Multivariate analysis
  • Advanced analytics
  • Predictive analytics

In Computer programming, running man is an icon which you can click on, in order to execute SAS code.

Read more on Statistical Analysis here: brainly.com/question/24439065

#SPJ1

7 0
2 years ago
What is it about Pinterest that makes it a good platform for ecommerce sites?
Inga [223]
With the large variance of items on the site it is easy to invest in an idea
5 0
4 years ago
Read 2 more answers
Which one of the following terms is defined as the material and surfaces upon which an artist works?1. Applied arts2. Context3.
babunello [35]

Answer:

The correct answer to the following question will be Option D (Media).

Explanation:

Media are the contact channels or devices used to store information or data and distribute it. The phrase refers to elements of the media marketing industry such as printed media, printing, mainstream media, film, theater, television and radio broadcast, and advertisement.

There are mainly three types of media, which are as follows:

  • Print media
  • Broadcast media
  • Internet

Using these three media, we can describe the content and the surfaces on which an artist works.

Therefore, Option D is the right answer.

5 0
3 years ago
What is adware?
Mila [183]

Software that, while purporting to serve some useful function and often fulfilling that function, also allows Internet advertisers to display advertisements without the consent of the computer user.

7 0
3 years ago
How do you remove management from your chrome book [administrator]
torisob [31]

I’m pretty sure you shouldn’t because in the form they have you fill I think you agree to something about the management so..

3 0
3 years ago
Other questions:
  • At the end of your presentation, the main points should be a. Summarized c. Handed to your teacher b. Written on the board d. Re
    7·2 answers
  • You’ve received a tarball called data79.tar from a colleague, but you want to check the names of the files it contains before ex
    15·1 answer
  • What type of strategy is being used by a website like www.CNNMoney when it describes itself as ""a one-stop destination covering
    14·2 answers
  • Elisa and Josh need to access General Help. Elisa will press the F1 key. Josh will click on ? in the upper-right corner of the W
    14·2 answers
  • Ethernet is a standard for a) LAN b) MAN c) WAN d) All of the above
    14·2 answers
  • This function receives first_name and last_name, then prints a formatted string of "Name: last_name, first_name" if both names a
    5·1 answer
  • WILL MARK BRAINILY!!
    9·2 answers
  • HELP MEEE PLEASE!!!
    11·1 answer
  • Does anyone know how to do Python Essentials 5.7.1.6 because i am completely lost
    5·1 answer
  • Help debugging line 7 type error more arguments (5) than expected (1)
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!