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
Aleonysh [2.5K]
3 years ago
8

Python Better Password Prompt

Computers and Technology
1 answer:
faust18 [17]3 years ago
3 0

We use an indefinite while loop to keep the user entering the password. In the loop, we use if-else structure to check the password. If it is "abc123", the password is found and stop the loop using a break. Otherwise, the password is not correct. Note that since we do not use any break statement in the else part, the loop will continue asking for the input

Comments are used to explain each line of the code.

You may see the output in the attachment.

#set the SECRET

SECRET = "abc123"

#create a loop

while True:

   

   #ask the user to enter a password

   password = input("Enter password: ")

   

   #check if the password is equal to SECRET

   # if it is, state that password is correct and stop the loop using a break

   # otherwise, state that password is not correct

   if password == SECRET:

       print("You got it!")

       break

   else:

       print("Sorry, that did not match. Please try again.")

Here is another question related to the loops:

brainly.com/question/25694810

You might be interested in
What is cell address?​
Nat2105 [25]

Answer:

A cell reference, or cell address, is an alphanumeric value used to identify a specific cell in a spreadsheet. Each cell address contains “one or more letters” followed by a number. The letter or letters identify the column and the number represents the row.

Explanation:

3 0
3 years ago
Each webpage is assigned a(n) ______, an address that identifies the location of the page on the Internet.
timofeeve [1]

Answer:

The answer is "URL".

Explanation:

The term URL is also known as the "Uniform-Resource-Locator", which is also known as the address of the website or internet file. To access this file we use to type its address in the web browser by using the "http:// or https://" protocol. It contains the domain name, with several other basic data to guide a visitor to a certain internet website called a web page.

5 0
3 years ago
For problems 14 – 21 determine all the roots of the given function.
lesya [120]
What’s the problem ?
7 0
3 years ago
Read 2 more answers
In the ________ step the data is either written to the file or read from the file.
nexus9112 [7]
I believe the step is <span>Insertion </span>
7 0
3 years ago
E Web Slice Gallery -
Verdich [7]

Answer:

C. Since he was hungry, she had a snack

Explanation:

So, you can say, " Claire is princes." In this "Claire happens to be the subject, " and Princes is the object. And apart from this a complete sentence must be enough to put forward a complete task. Now in C. we see complete thought is shared. Whereas in no other sentence complete thought has been revealed, and they are incomplete. And hence, the correct option is C.  

3 0
3 years ago
Other questions:
  • What can I play to get max points
    9·2 answers
  • Claire wants to be a digital media coordinator. What requirements does she need to fulfill in order to pursue this career?
    6·1 answer
  • Why should you use a named constant for the size of an array?
    9·1 answer
  • Like Tess, Brina has a fascinating job! She works as a software engineer with Instagram. She says that Computer Science is a way
    10·2 answers
  • ____ is used specifically for the purpose of recording keystrokes, logging the programs or Web sites accessed, or otherwise moni
    6·2 answers
  • The following processes are being scheduled using a preemptive, round-robin scheduling algorithm. Each process is assigned a num
    6·1 answer
  • A company has an Aruba solution. The company wants to host a guest login portal with this solution, and the login portal must gi
    7·1 answer
  • How did transistors revolutionize the world of computers?
    15·1 answer
  • Clickable text or images that take you to different sites on the World Wide Web are called __________.
    13·2 answers
  • What is a zerø-day exploit? No go.ogle &gt;:(
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!