I'm having a hard time with a loop I put in this code I have can anyone help me it would be much appreaited? x = float(raw_input('enter your password: ')) a = float(10.0) while x != a: print 'password rejected' print 'you are an idiot' float(raw_input('please enter the correct password:')) else: print 'password accepted' print 'Hello Apple'
You merely missed to write x = float(raw_input('please enter the correct password:')) after the while loop so it should be as @bwCA stated ;)
in case you're wondering why. It's pretty simple. :) If the user wrote the password "10", the password will be accepted. But if he misses it the first time and writes sth else like "20" for instance and the 'password rejected' & 'you are an idiot' notes appear and he is required to attempt to write a new password, a new "x" ..and he does write 10...It will not be assigned to "x" because you didn't mention that/didn't assign it. Hope I helped :)
Join our real-time social learning platform and learn together with your friends!