That code seems to work if the user gets name/password right on the first attempt. If they don't, any further attempts will fail because line 16 pass=pass+c; means the password keeps getting longer and longer - including all the previous failed attempts.