Python Forum
Recursive function not returning expected output...(Python speech recog module)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Recursive function not returning expected output...(Python speech recog module)
#3
(Jan-07-2017, 04:18 AM)ichabod801 Wrote: First of all, I think it would be much better to rewrite this as a loop rather than recursion.

Second, the reason it doesn't return anything if it recuses is that you don't return anything from the recursive call. Instead of hey_pc(), you want return hey_pc(). That way the return value of one will be passed up the recursion chain to the initial call at the bottom of the program.


Thanks for the reply. I will test out your suggestion.

As for your loop suggestion, are you suggesting a WHILE loop? I will think about it see if I can come up with something.


Edit: Thanks seems to be working once I replace the two hey_pc to return hey_pc. I will play around with it some more.
Reply


Messages In This Thread
RE: Recursive function not returning expected output...(Python speech recog module) - by bigmit37 - Jan-07-2017, 06:35 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python trivial endgame engine is not working as expected max22 0 576 Feb-24-2024, 04:41 PM
Last Post: max22
  problem in output of a function akbarza 9 1,328 Sep-29-2023, 11:13 AM
Last Post: snippsat
  Recursive regular expressions in Python risu252 2 1,348 Jul-25-2023, 12:59 PM
Last Post: risu252
  with open context inside of a recursive function billykid999 1 608 May-23-2023, 02:37 AM
Last Post: deanhystad
  My code displays too much output when importing class from a module lil_e 4 1,229 Oct-22-2022, 12:56 AM
Last Post: Larz60+
  Facing problem with Pycharm - Not getting the expected output amortal03 1 889 Sep-09-2022, 05:44 PM
Last Post: Yoriz
  How to print the output of a defined function bshoushtarian 4 1,364 Sep-08-2022, 01:44 PM
Last Post: deanhystad
  Why my function is returning None? PauloDAS 6 1,858 Jul-17-2022, 11:17 PM
Last Post: Skaperen
  output correction using print() function afefDXCTN 3 11,235 Sep-18-2021, 06:57 PM
Last Post: Sky_Mx
  python prints none in function output chairmanme0wme0w 3 2,285 Jul-07-2021, 05:18 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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