'I want to check if username has any Character from blockCharacter but i could'nt do it [duplicate]
I want to check if username has any Character from blockCharacter but i could'nt do it and this is my code
user = input("Whats your name\n").lower()
user = (user.title())
BlockChar = ["+","none","-"]
if user == BlockChar:
print("That does'nt not feels right. Try Again")
breakpoint
print ("Welcome " + user)
I am new to codeing and stack overflow so i need some help with it
Solution 1:[1]
The any function and a generator expression will work quite nicely to determine if any of the strings in BlockChar are in your user string.
if any(ch in user for ch in BlockChar):
...
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Chris |
