if < insert condition here>:
Note: You must indent the line after the if statement and the else statement. Also, you must put a colon after the condition.
So if for example variable "a" is 1 and you want to do something if it is 4, then you write this:
if a == 4:
< insert action here >
Note: you use one equals sign to set things equal to each other, but you use two to compare them. That is why I used one in the variables post and two in this post.
If you want it to do something if "a" = 4 but somethng else if it isn't, then do this:
if a == 4:
<
else:
<
Note: Always remember to put the colon after else otherwise it won't work.
Next post: elif command
No comments:
Post a Comment