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


Groups > comp.lang.python > #78589 > unrolled thread

Re: Function passed as an argument returns none

Started byShiva <shivaji_tn@yahoo.com>
First post2014-10-02 08:46 +0000
Last post2014-10-02 08:46 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

#78589 — Re: Function passed as an argument returns none

FromShiva <shivaji_tn@yahoo.com>
Date2014-10-02 08:46 +0000
SubjectRe: Function passed as an argument returns none
Message-ID<mailman.14545.1412239590.18130.python-list@python.org>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web