Monday, 10 May 2021

.count(): function to not accept a password with a certain character

 def tabsie():
    string=input("give a text")

    if string.count("-") > 0: #this means if you have a dash (-) more than 0,
        print("you cant have - in the string")
        tabsie()#we need to start the function from the beginning.
    else:
        print(" nice!okay ")
tabsie()#lets run the function and see.

No comments:

Post a Comment