Jump to content

need looping help

- - - - -

  • Please log in to reply
2 replies to this topic

#1
BRUTAL

BRUTAL

    Newbie

  • Members
  • PipPip
  • 22 posts
Hey guys got my program running..sorta heres the deal im making a login script and if they dont get the login right then they have to solve a mathmatical problem and if they get it right then it tells them the login problem is that if they get the problem wrong then it loops them back to the login which is very inconvient how do i change this.
while True:
username = raw_input('Username: ')
password = raw_input('Password: ')

if username == 'Uname' and password == 'Pword':
print 'Welcome'
raw_input("press any key to exit")
break
else:

problem = 22
while problem == 22:
problem = int(raw_input('ERROR ACCESS DENIED, Solve to lift quarantine\n(7 * 3) - 3 + 4: '))
if problem == 22:
print ('Quarantine lifted, username is Uname and password is Pword')

break
else:
print ('invalid')

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
You need to use code tags. (the # button) Without those we can't see your indentation.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
Flying Dutchman

Flying Dutchman

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 890 posts
  • Location:::1
Your problem is that once the user enters mathematical solution, and if wrong, it will overwrite problem variable and will no longer be 22 thus loop will stop.
A conclusion is where you got tired of thinking.
#define class struct    // All is public.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users