if with else : If « Language Basics « Python






if with else

if with else

name = raw_input('What is your name? ')
if name.endswith('Yin'):
    print 'Hello, Mr. Yin'
else:
    print 'Hello, stranger'

           
       








Related examples in the same category

1.Nested if statementNested if statement
2.if-else structureif-else structure
3.if-elif-else structureif-elif-else structure
4.if structureif structure
5.if Statements: if, elif and elseif Statements: if, elif and else
6.Boolean operation in ifBoolean operation in if
7.elif demoelif demo
8.If statement: a dictionary-based 'switch'If statement: a dictionary-based 'switch'
9.Leap Year checkerLeap Year checker