Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #78589

Re: Function passed as an argument returns none

From Shiva <shivaji_tn@yahoo.com>
Subject Re: Function passed as an argument returns none
Date 2014-10-02 08:46 +0000
References <loom.20141002T003356-994@post.gmane.org>
Newsgroups comp.lang.python
Message-ID <mailman.14545.1412239590.18130.python-list@python.org> (permalink)

Show all headers | View raw


Hi All,

Thank you everyone. This is fantastic - I post a query and go to sleep and
by the time I get up there is already a nice little thread of discussion
going on.....

By the way, I sorted it with all your suggestions.

def donuts(count):
  if count <= 9:     #This had to be 9 instead of 5 as per the question req.
    return 'Number of donuts: {0}'.format(count)
  else:
    return 'Number of donuts: many'

So to summarise what I learnt:

* Just 'return' returns None - it is not related to what you print inside
the function.If you want something specific out of a function return
something specific.

* return 'Number of donuts: ',count    returns a tuple like:
('Number of donuts: ',9)

* To just print the string without returning it as tuple , use string
formatting.

Thanks again,
Shiva

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Function passed as an argument returns none Shiva <shivaji_tn@yahoo.com> - 2014-10-02 08:46 +0000

csiph-web