Looks like code was sent to a Python3 shell, where `print` is a function. <kbd>M-x</kbd> `py-execute-def-python2` <kbd>RET</kbd> should work. Customizing `py-shell-name` is an option too.