If Statements These statements are a bit like asking a question. You are telling the computer: if something is true, then do this specific block of code. Double equals ( == ) is asking the computer to compare if these two things are exactly the same. EXAMPLE : myName = input("What's your name?: ") if myName == "David": What is else? IF the condition is not met with the if statement, then we want the computer to do the else part instead. Likewise, if the condition is met in the if statement, then the else bit is ignored by the computer. The else statement must be the first thing unindented after the if statement and in line with it EXAMPLE : myName = input("What's your name?: ") if myName == "David": print("Welcome Dude!") print("You're just the baldest dude I've ever seen...
Comments
Post a Comment