Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

if-else Conditional Statement in Python

def authentication(password):
    if password == 'unstoppable':
        message = "Login Successful !! Welcome to the Softhunt"
    else:
        message = "Try a different password"
        
    return message
    
def main():
    print("Authentication System")
    print("======================")
    passwordInput = input("Enter your password: ")
    checkPass = authentication(passwordInput)
    print(checkPass)
main()
Comment

python conditional statement

num = 1

if num == 1:
   print("num is 1"))
elif num == 2:
   print("num is 2")
else:
   print('invalid number')
# output num is 1

# if the conditional is true the left side of side the expression is resolved else the right side is resolved
print("num is 2") if num == 2 else print("num is 1")
# output num is 1
Comment

PREVIOUS NEXT
Code Example
Python :: convert all sizes to terabytes pandas 
Python :: networkx node attribute from a dataframe 
Python :: Dictionary Cache 
Python :: how to access a file from root folder in python project 
Python :: split string by special characters python 
Python :: generative art python 
Python :: python linter 
Python :: python set workspace dir 
Python :: python trim zero off end of list 
Python :: tail a log file with python 
Python :: Set path for another directory 
Python :: Function in python with input method 
Python :: Generate hashed passwords for ansible 
Python :: pandas series map 
Python :: remove duplicates from list python keep order 
Python :: python loops 
Python :: change every element of list python with map 
Python :: django query filter greater than or equal to 
Python :: Model In View Django 
Python :: python latest version 64 bit 
Python :: return array of sorted objects 
Python :: * pattern by python 
Python :: find type of an element in list python 
Python :: how to know the version of python 
Python :: print torch model python 
Python :: django MESSAGE_TAGS 
Python :: current date to midnight 
Python :: Generate bar plot python 
Python :: examples of function in python 
Python :: xlrd documentation 
ADD CONTENT
Topic
Content
Source link
Name
1+4 =