function definition (pycharm) - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: function definition (pycharm) (/thread-7150.html) |
function definition (pycharm) - raulseangarciaroberts - Dec-23-2017 Ok so i´m new to coding and have ZERO experience in this...I am reading a book i found online and i am trying to do some of the activties that are shown in the book. I am using pycharm to test my coding. The code i am writing is as follows. >>> def print_lyrics(): ... print "lumber jacks" ... print "im a sleep" ... File "<input>", line 2 print "lumber jacks" ^ SyntaxError: Missing parentheses in call to 'print' The book says "to end the function, you have to enter an empty line ( this is not necessary in a script)." I understand that the three dots means that the definition is not complete...so how do i complete the freakin thing??? I just want to define lyrics as lumberjacks and im a sleep, right...thats what im trying to do?? This has got to be a simple misunderstanding... Link of book >>> http://www.greenteapress.com/thinkpython/thinkCSpy/html/chap01.html Im on chapter 3 functions 3.5 section thank you for reading and hope that made sense. RE: function definition (pycharm) - ezdev - Dec-23-2017 i bet youre using the python 2 version of thinkpython. as the page says, you probably want this: http://greenteapress.com/wp/think-python-2e/ also: print("lumber jacks") RE: function definition (pycharm) - Larz60+ - Dec-23-2017 Originally, python would cause an assertion error if the code did not end in newline. (see https://pypi.python.org/pypi/pep8/1.7.1) 1.4, 3rd item this was corrected PEP8 issue #119 and is no longer required. It's probably left over in PyCharm from this old issue. I always end code with a newline, not because it's required, but that I don't personally feel it's complete without it. RE: function definition (pycharm) - raulseangarciaroberts - Dec-25-2017 I figured out the problem with your guys posts! thank you two very much! |