Maker Pro
Maker Pro

Python programming course help

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
I'm not sure what you mean. It seems to behave the way I expected. When it gets to line 4 and s="n" it will call itself one more time with s="". That could be avoided by checking for len(s) > 1 before calling prend() again, but that duplicates the check that already has to be made in line 2 to prevent the function from doing anything if passed an empty string.

So calling prend() unnecessarily with an empty string once at the end of the string may or may not be less efficient than checking twice each time through. But it seems to work as expected.
 

chopnhack

Apr 28, 2014
1,576
Joined
Apr 28, 2014
Messages
1,576
I'm not sure what you mean. It seems to behave the way I expected. When it gets to line 4 and s="n" it will call itself one more time with s="". That could be avoided by checking for len(s) > 1 before calling prend() again, but that duplicates the check that already has to be made in line 2 to prevent the function from doing anything if passed an empty string.

So calling prend() unnecessarily with an empty string once at the end of the string may or may not be less efficient than checking twice each time through. But it seems to work as expected.

I liked your Turing test Kris - are you a real person? :p You didn't expect me on the other end?:D

It did work fine, I was just surprised that it didn't terminate at the end of the string length, it might have been the site software for all we know - but you did see it after 'n', it returned no value then it seemed to continue to work through the old output that was on the right hand side of the screen return no value and removing the entries. I just found it odd, no more than an aside, thank you again as the example helps quite a bit. I am visualizing the Fibonacci routine right now, should be interesting to see step by step! Thanks for checking in with me on that, I really appreciate it :D:D
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
Oh sorry! I didn't think that "Gregarious Giraffe" would be you! I assumed it was either a bot or someone the site assigned to help me.

No problem :) I like that site as well.
 

chopnhack

Apr 28, 2014
1,576
Joined
Apr 28, 2014
Messages
1,576
Oh sorry! I didn't think that "Gregarious Giraffe" would be you! I assumed it was either a bot or someone the site assigned to help me.

No problem :) I like that site as well.

Dude, you were Wacky Whale, ROFL lol - I didn't get to see my name, it just said 'me' - ROFL, ROFL - Gregarious Giraffe, that is awesome!!! haahaaahhahaha

Yes, I think that site has helped me tremendously!

So it happened again with Fibonacci - I think what I am seeing is the temporary value field - i.e. the recursion loop's secondary variable storage if that makes sense - not the global variable. It was easier to follow with Fibonacci, because I could see what it was doing, adding the precedent to the latter and tallying it up and so forth. Recursion is a bit tricky to follow, but damn useful - saves tons of coding over iteration!! This is a cool tool and I want to get it firmly under the belt! Thanks again Kris!
 
Top