Lec 1-3.. Conditional Statements section of Python Programming http://en.wikibooks.org/wiki/Python_Programming/Conditional_Statements Bottom of the page under "If exercises", Question #1. I tried to do it without looking at the answer key. I'm brand new to thinking like a computer scientist so bear with me. I used the WHILE loop. And the result was the program saying "try again", "try again", "try again", "you've been denied", after inputting the wrong password. It did not ask me/the user for the password 3 different times because it's a WHILE loop instead of a FOR loop, right?

At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get our expert's

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this and thousands of other questions.

A community for students.

Lec 1-3.. Conditional Statements section of Python Programming http://en.wikibooks.org/wiki/Python_Programming/Conditional_Statements Bottom of the page under "If exercises", Question #1. I tried to do it without looking at the answer key. I'm brand new to thinking like a computer scientist so bear with me. I used the WHILE loop. And the result was the program saying "try again", "try again", "try again", "you've been denied", after inputting the wrong password. It did not ask me/the user for the password 3 different times because it's a WHILE loop instead of a FOR loop, right?

MIT 6.00 Intro Computer Science (OCW)
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this and thousands of other questions

http://pastebin.com/YKYpQWg9 Here is the code. The program is up top along with getting the password correct, and getting the password incorrect. 2) Another issue that comes up is that after I input a password, the program will run and I will get a popup stating "Program is still running, kill it?". If I press OK, it will exit the Python IDE. Real annoying. If I press cancel, I get those errors. (shown in the pastebin).
It didn't ask you for the password three different times because your input() function is outside the loop. The input function is what prompts the user. You need to put it in the loop somewhere in order to ask the user more than once.
Thanks that worked for me. I learned something yet again. Here is the new program: http://pastebin.com/2dDXtu60 Why doe the answer key use a FOR loop? It says: For i in range (1,4): blah blah blah. And makes the loop go through the for loop and when i==3, it stops. It appears the end results are the same. My program with the WHILE loop seems to accomplish the same thing. Is there any benefit to using the FOR loop? Or different strokes for different people? Secondly, I noticed that if I remove exit() from the code, the Python IDE will not give me a popup stating that "the program is still running, kill it?" Does that mean that exit() is actually workng properly and that it is trying to close out of Python IDE??

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

I'm only a beginner myself. Exit will kill the program. a better way of exiting from a function is the 'return' statement. 'return' can also pass back the result of a function to which ever part of the program that called it
also using input is a bad idea. best to use raw_input() and then extract from the string what you need.
Well Python 3.2 doesn't have raw_input() if I'm not mistaken. I dont know enough to know the difference but I read that 3.2 made raw_input just input().

Not the answer you are looking for?

Search for more explanations.

Ask your own question