Finding a substring in a string : String startsWith : String PYTHON examples


PYTHON examples » String » String startsWith »

 

Finding a substring in a string


Finding a substring in a string

string2 = "Odd or even"

# find index of "even"
try:
   print '"even" index is', string2.index( "even" )
except ValueError:
   print '"even" does not occur in "%s"' % string2

if string2.startswith( "Odd" ):
   print '"%s" starts with "Odd"' % string2

if string2.endswith( "even" ):
   print '"%s" ends with "even"n' % string2

           
       



    Related Scripts with Example Source Code in same category :

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON examples

 Navioo String
» String startsWith