syntax error on `If` line
Question: My code:

    
    
    #!/usr/bin/env python
    
    def Runaaall(aaa):
      Objects9(1.0, 2.0)
    
    def Objects9(aaa1, aaa2):
      If aaa2 != 0: print aaa1 / aaa2
    

The error I receive:

    
    
    $ python test2.py 
      File "test2.py", line 7
        If aaa2 != 0: print aaa1 / aaa2
              ^
    SyntaxError: invalid syntax
    

I'm at a loss to why this error is happening.


Answer: `if` must be written in lower case.

Furthermore,

  * Write function names in lower case (see [PEP 8](http://www.python.org/dev/peps/pep-0008/), the Python style guide).
  * Write the body of an `if`-clause on a separate line.
  * Though in this case you'll probably not run into trouble, be careful with [comparing floats for equality](http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm).
  * Since you've just started learning Python, you may want to get acquainted with writing parentheses around the arguments to `print`, since from Python 3 onwards, [print is a function](http://docs.python.org/dev/3.0/whatsnew/3.0.html), not a keyword.  
To enforce this syntax in Python 2.6, you can put this at the top of your
file:

    
        from __future__ import print_function
    

Demonstration:

    
        >>> print 'test'
    test
    >>> from __future__ import print_function
    >>> print 'test'
      File "<stdin>", line 1
        print 'test'
                   ^
    SyntaxError: invalid syntax
    >>> print('test')
    test
    

For more on `__future__` imports, see the
[documentation](http://docs.python.org/3.1/library/%5F%5Ffuture%5F%5F.html).

