Python Forum
Why is the function returning None for a * b instead of number?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why is the function returning None for a * b instead of number?
#11
@buran - Yes, I could have messed up with my interpretation. Thanks for the suggestion.
@perfringo - Thanks a ton for clearly explaining it.
and @deanhystad - Thanks for the better way of coding. I was trying to solve it in a crude way and then learn from the alternate solutions after solving it. When I was coding this, I had a feeling that I was not doing it the right way but, first wanted to solve it one way or the other and later try for better way. But, looks like I have totally screwed the way functions are supposed to be used. Thanks for correcting me.

I have started solving questions on http://codewars.com and this is one among them.
write calculations using functions and get the results. Let's have a look at some examples:
seven(times(five())) # must return 35
four(plus(nine())) # must return 13
eight(minus(three())) # must return 5
six(divided_by(two())) # must return 3


I am first trying to solve it (could be a crude way) and once I am done, I am finding other solutions and learning from them.

Thanks for all your suggestions. I am working on improving myself.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Why my function is returning None? PauloDAS 6 1,754 Jul-17-2022, 11:17 PM
Last Post: Skaperen
  Checking the number of arguments a function takes Chirumer 3 2,153 Jul-06-2021, 04:56 PM
Last Post: Chirumer
  Pausing and returning to function? wallgraffiti 1 2,160 Apr-29-2021, 05:30 PM
Last Post: bowlofred
  is there a single function to confine a number between two others? Skaperen 7 2,813 Nov-28-2020, 06:10 PM
Last Post: Skaperen
  Having hard time understanding the function self-returning itself twice jagasrik 2 2,484 Aug-15-2020, 08:50 PM
Last Post: deanhystad
  RuntimeError: Optimal parameters not found: Number of calls to function has reached m bntayfur 0 6,141 Aug-05-2020, 04:41 PM
Last Post: bntayfur
  basic random number generator in replace function krug123 2 2,038 Jul-31-2020, 01:02 PM
Last Post: deanhystad
  Returning Value from Function with Trackbars vicpylon 3 2,057 May-24-2020, 11:28 PM
Last Post: bowlofred
  Nested Recursive Function not Returning Etotheitau 2 2,256 May-09-2020, 06:09 PM
Last Post: Etotheitau
  Mysql returning number of rows not data AkaAndrew123 4 2,805 Jun-10-2019, 02:31 PM
Last Post: AkaAndrew123

Forum Jump:

User Panel Messages

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