Bobys
Bobys

Reputation: 677

Stars(****) instead of actual password

Im on a raspberry Pi project right now, and I stack somehow.

These are some parts of my code:

#some standard passwords
attempt = "0000"
passcode = "1234"    
haltcode = "4321"

#Getting the digits from the adafruit Keypad and store it to digit
while digit == None:
          digit = kp.getKey()

#Add each digit to attempt variable
attempt = (attempt[1:] + str(digit))  

#Clear and write on the LCD Screen
lcd.clear()
lcd.message("Password: " + attempt)

#Checking for the correct passwords
if (attempt == passcode):
    blah blah blah

if (attempt == haltcode):
    blah blah blah

I would like instead of the actual password, to print starts on the lcd scene. For example:

User enters 1-> Password: *
Then
User enters 2-> Password: **
Then
User enters 3-> Password: ***
Then
User enters 4-> Password: ****

Like the mobile phone when you enter your sims pin. I don't know how this is possible. I would be more than grateful if you share with me some hints. Thank you

Upvotes: 0

Views: 220

Answers (1)

Ben
Ben

Reputation: 2133

Looks like this is the line that does the printing (don't know, never worked with a RPi with peripherals before):

lcd.message("Password: " + attempt)

If that's the case:

lcd.message("Password: *")

Change the number of asterisks based on how many numbers have been entered so far

Upvotes: 1

Related Questions