If Statement - Nested Conditional Using Modulus Operator in Python
<p>I need to create a program in Python that asks the user for a number, then tells the user if that number is even or if it's divisible by 5. If neither is true, do not print anything. For example: </p>

<pre><code>Please enter a number: 5

    This number is divisible by 5!

Please enter a number: 7

Please enter a number: 20

    This number is even!

    This number is divisible by 5!
</code></pre>

<p>I tried to copy the method that was used in <a href="http://stackoverflow.com/questions/8002217/how-do-you-check-whether-a-number-is-divisible-by-another-number-python">this answer</a>, but I'm getting an error message on line 8: </p>

<pre><code>SyntaxError: invalid syntax (&lt;string&gt;, line 8) (if Num_1 % 2 == 0)
</code></pre>

<p>Here is my code: </p>

<pre><code>#TODO 1: Ask for user input
Num1 = input("Please enter a number")
#TODO 2: Turn input into integer
Num_1 = int(Num1)
#TODO 2: Use conditionals to tell the user whether or not their
#number is even and/or divisible by 5

if Num_1 % 2 == 0
    print ("This number is even!")
        if Num_1 % 5 == 0 
            print ("This number is divisible by 5!")
</code></pre>

<p>Since I'm using the modulus operator to determine whether or not Num_1 is an exact multiple of 2, I should be returning a value of True and therefore should print "This number is even!" But instead I'm getting this error message - why? Thanks!</p>

<p>The start of each Python block should end with a colon <code>:</code>. Also take note of the indentation.</p>

<pre><code>Num1 = input("Please enter a number")
Num_1 = int(Num1)

if Num_1 % 2 == 0:
    print ("This number is even!")
    if Num_1 % 5 == 0:
        print ("This number is divisible by 5!")
</code></pre>

python if-statement int modulus