Trying myself now at a little more simple stuff as a bloody python newbie:
Read into it here and there but still quite don't get it. This code works, but if entering a wrong password, it doesn't print out that the password is wrong. It just asks again to enter the right password, which is fine. But without printing that it's the wrong password. I like small, readable and simple code so I did it this way, but can you tell me where is my mistake?
Edit: I tried searching this in stackexchange and various google sites too. Although it's one of the most simple things, I always got examples that where way different and where I had a hard time understanding it. Now I got it. (First 2 answers)
while True:
password = raw_input('Enter Password: ')
if password == 'secret':
print 'Password correct!'
break
if password == False:
print 'Password incorrect!'
According to how I understood it: The code doesn't even get to run to the point of "if password == False:" and only does a "break" until the 'secret' has been entered. Could it be that I have to move the part
if password == False:
print 'Password incorrect!'
somewhere else to it to work?
Thanks a lot for every kind help!