Python if statement

if statement:

#!/usr/bin/python
# -*- coding: UTF-8 -*-
flag=False                                                                                                                                                           
name = 'Charles'
if name == 'python': # Check if the variable is 'python'
    flag = True # set the flag to true when the condition is true
    print('welcome boss') # and print welcome message
else:
    print (name) # output variable name if condition is not true

result:

Charles


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324896119&siteId=291194637