Python Forum
help needed plz, how to check if a string is almost the same?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
help needed plz, how to check if a string is almost the same?
#2
You can write a function to normalize the user input, then write
norm_username = normalize(username)
if norm_username == 'jack':
    ...
For example the following function normalizes the user name to the first word of the input in lowercase characters
def normalize(username):
    return username.split()[0].lower()
Reply


Messages In This Thread
RE: help needed plz - by Gribouillis - Apr-25-2019, 10:09 AM
RE: help needed plz - by perfringo - Apr-25-2019, 02:11 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How do I check if the first X characters of a string are numbers? FirstBornAlbratross 6 1,798 Apr-12-2023, 10:39 AM
Last Post: jefsummers
  how to check if string contains ALL words from the list? zarize 6 7,667 Jul-22-2020, 07:04 PM
Last Post: zarize
  How to check if user entered string or integer or float?? prateek3 5 11,572 Dec-21-2019, 06:24 PM
Last Post: DreamingInsanity
  How to check if value of a list is in a string? HiImNew 2 4,096 Dec-07-2017, 10:07 PM
Last Post: Larz60+
  Ho to check if string contains substring from list Rius2 2 76,820 Sep-30-2017, 07:32 PM
Last Post: Rius2
  Check to see if a string exactly matches an element in a list DBS 1 22,676 Nov-02-2016, 10:16 PM
Last Post: Ofnuts

Forum Jump:

User Panel Messages

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