Function passed as an argument returns none
shivaji_tn at yahoo.com
Thu Oct 2 00:37:13 CEST 2014
I am learning Python (version 3.4) strings.I have a function that takes in a
parameter and prints it out as given below.
if count <= 5:
print('Number of donuts: ',count)
print('Number of donuts: many')
It works fine if I call
we have 5 DN (as expected)
However if I do :
test(donuts(4), 'Number of donuts: 4')
where test is defined as below:
def test(got, expected):
print('got: ', got, 'Expected:' ,expected)
if got == expected:
prefix = ' OK '
prefix = ' X '
print (('%s got: %s expected: %s') % (prefix, repr(got), repr(expected)))
Only 'None' gets passed on to parameter 'got' instead of the expected value
Any idea why 'None' is getting passed even though calling the donuts(4)
alone returns the expected value?
More information about the Python-list