Python Forum

Full Version: Amount of letters in a inputted string?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm not sure how to make it so that if the password has less than 5 letters, it says Please select a longer password!


password = input("Please enter a password. ")
import time
time.sleep(0.3)
if password <= len int(5):
    password2long = input("Please select a longer password ")
else :
    verifypassword = input("Please confirm your password. ")
if len(password) <= 5:
Also you will probably want to wrap some of this in a while loop so it continues to ask on faulty input rather than just ends.
if len(password) < 5:
and why on Earth you should use time.sleep()? Not that user will really notice 0.3 sec pause
Instead of input, you should probably use getpass, so whatever they type doesn't get displayed on the screen: https://docs.python.org/3.6/library/getpass.html