python if statements using letters code example

Example 1: how to check a string in if statement python

if var == 'stringone' or var == 'stringtwo':
    dosomething()

Example 2: how to check a string in if statement python

if var is 'stringone' or 'stringtwo':
    dosomething()

Example 3: how to check a string in if statement python

if var in ('stringone', 'stringtwo'):
    dosomething()

Example 4: how to check a string in if statement python

if var == 'stringone' or var == 'stringtwo':
    do_something()

Example 5: how to check a string in if statement python

if var in ['string one', 'string two']:
    do_something()