Python Forum
function definition (pycharm)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
function definition (pycharm)
#1
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...hap01.html

Im on chapter 3 functions 3.5 section

thank you for reading and hope that made sense.
Reply
#2
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")
Reply
#3
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.
Reply
#4
I figured out the problem with your guys posts! thank you two very much!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  mutable argument in function definition akbarza 1 423 Dec-15-2023, 02:00 PM
Last Post: deanhystad
  error occuring in definition a class akbarza 3 636 Nov-26-2023, 09:28 AM
Last Post: Yoriz
  determine parameter type in definition function akbarza 1 550 Aug-24-2023, 01:46 PM
Last Post: deanhystad
  [split] Explain the python code in this definition Led_Zeppelin 1 711 Jan-13-2023, 10:20 PM
Last Post: deanhystad
  Explain the python code in this definition Led_Zeppelin 1 1,059 Oct-27-2022, 04:04 AM
Last Post: deanhystad
  meaning of -> syntax in function definition DrakeSoft 5 1,877 Apr-09-2022, 07:45 AM
Last Post: DrakeSoft
  Not including a constructor __init__ in the class definition... bytecrunch 3 11,517 Sep-02-2021, 04:40 AM
Last Post: deanhystad
  Something wrong with the quotation mark in dictionary definition Mark17 1 1,958 Jan-29-2021, 03:34 PM
Last Post: buran
  Definition of .format? (Newbie question) Jan_97 4 2,640 Jul-13-2019, 12:49 PM
Last Post: Jan_97
  How does this definition/directory work? mistertimmy952 2 2,536 Nov-07-2018, 08:57 AM
Last Post: mistertimmy952

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020