Python Forum
Amount of letters in a inputted string?
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Amount of letters in a inputted string?
#1
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. ")
Reply
#2
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.
Reply
#3
if len(password) < 5:
and why on Earth you should use time.sleep()? Not that user will really notice 0.3 sec pause
Reply
#4
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Get amount of bytes in a file chesschaser 1 1,544 Aug-23-2021, 03:24 PM
Last Post: deanhystad
  Replacing a words' letters in a string cananb 2 3,407 Dec-01-2020, 06:33 PM
Last Post: perfringo
  Moving large amount of data between MySql and Sql Server using Python ste80adr 4 3,326 Apr-24-2020, 01:24 PM
Last Post: Jeff900
  Select single letters from string based on separate string Jpen10 3 2,631 Dec-15-2019, 01:21 PM
Last Post: Jpen10
  getting first letters of a string Unknown_Relic 1 1,681 Nov-12-2019, 11:16 AM
Last Post: perfringo
  SQL query with a variable amount of parameters Antares 10 6,743 Jul-08-2019, 02:24 PM
Last Post: Antares
  Counting the number of letters in a string alphabetically TreasureDragon 2 2,851 Mar-07-2019, 01:03 AM
Last Post: TreasureDragon
  Replacing all letters in a string apart from the first letter in each word Carbonix 9 4,835 Jan-17-2019, 09:29 AM
Last Post: buran
  Have an amount of time to perform and action CookieGamez2018 1 2,916 Dec-21-2018, 07:12 AM
Last Post: Gribouillis
  Help Convert difference between inputted date and now aspeniii 1 2,341 Nov-30-2018, 07:31 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020