I know how to do this if I iterate through all of the characters in the string but I am looking for a more elegant method.
A regular expression will do the trick with very little code:
import re ... if re.match("^[A-Za-z0-9_-]*$", my_little_string): # do something here
1.4m articles
1.4m replys
5 comments
57.0k users