check if special character in string python

string = "Daneshwar$/?$Daneshwar"
regex = re.compile('[@_!#$%^&*()<>?/\|}{~:]')
if(regex.search(string) == None):
	print("special is absent")
else:
	print("present")

Here is what the above code is Doing:
1. We first import the re module.
2. We then use re.compile() so we can use regex.
3. Pass the string you want to check into re.compile().
4. We use regex.search() to search for the pattern in string.
5. If the pattern is found, regex.search() returns a match object.
6. If the pattern is not found, regex.search() returns None.
7. We use if…else to check if the pattern is found or not.