def...: in python code example
Example 1: how to use def in python
def functionName(variable):
//function content
Example 2: python def
#Use this to shortern a task that you may want to repeat
#Used for making custom commands
def paste(a, b)
for i in b:
print(a)
while True:
paste("Python is Cool!!!", 3)
#Output:
#Python is Cool!!!
#Python is Cool!!!
#Python is Cool!!!
## - ANOTHER EXAMPLE - ##
happy = "NEUTRAL"
def yes():
happy="TRUE"
print("Thank you!")
def no():
happy="FALSE"
print("That's not nice!")
answer=str(input("Do you like my new shoes? (y/n) ")
if answer=="yes" or "y" or "Yes" or "Y" or "YES":
yes()
elif answer=="no" or "n" or "No" or "N" or "NO":
no()