I have a friend who was needing help with a DEF statement so I thought that others might need help with it so I went and made an explanation of how to make a DEF statement and made a lot of comments I am sure I have a few spelling mistakes in it so if y’all would see if there’s anything wrong just tell me Im sure @QwertyQwerty88 will find many Thank you!
This will go over how to create a function and tell you what everything does and I will create comments(#) on it.
# Create a DEF or define statement
# Then you will label it by a name of your choice, for this project I will be using the content "names"
# After you do that you will use the () to close it off and come back to it after
# Then you use the : like you would in an IF statement to have it tab over and be in the correct indentation
# I am now asking the user to give me their name. I used the \n to go to a new line then the \t to tab the line over and printed "Name:" then did \t to tab it over again (I do that for it to just look nice) (You can see what it does when you hit run)
name = input('What is your name?\n\tName:\t')
# I will now use an IF statement after the input statement and say if their name (.lower() so that it will be all lower case) is "chandler" then it will follow the function here
if name.lower() == 'chandler':
# Then it will print that chandler is the best name ever after the if statement
print('You have the best name ever Chandler!')
# Then we will use an ELSE statement to say if their name doesn't fall into the parameters of the IF statement it will do what's under the ELSE statement
# Under the ELSE statement it will say that whatever name they have given it will say its a good name (It uses .title() so that when it prints the name back it will have a capital letter for the first letter)
print('The name',name.upper(),'is a good name.')
# Here we will call back to the start so that it will now do the statement you must use this or you will get an error