Good Evening All,

I'm doing a small application using python. I want to check the special characters of the ASCII values with the given characters in the text box.
if(string1.rindex!="char(32)" and string2.rindex!="char(32)")
message("You have entered the special characters")
check the values in the database and it follows.

Thanks for helping me.
warm Regards

if string1.rindex(chr(32)) and string2.rindex(chr(32)):
      print "You have entered the special characters"

That is how you would write the code however this probably isn't the best way as an exception is thrown if the case comes back false something like a for loop would probably be better

for i in string1:
   if i == ' ':         # ' '   is chr(32)
      print 'special character found'

A quicker way would be to check if a split() results in a list with length greater than 1:

>>> s1 = 'Test string'
>>> s2 = 'Test'
>>> s1.split()
['Test', 'string']
>>> s2.split()
>>> len(s1.split())
>>> len(s2.split())

On second thought, it'd be easier to just do a direct check like this:

>>> def check4space( s ):
...     """ Checks for spaces in the input string s
...         returns True or False """
...     return ' ' in s
>>> check4space( 'This is a test string' )
>>> check4space( 'Foobar' )
>>> check4space( '13457890)(*&^%$#@!' )