Problem Set 2, #3
for some reason it isnt working, when launched it just remains a blank screen
I just did it this morning. I'll take a look at it.
The only I see wrong right off the back is you never assigned in in your test statement to fix that you can add 1 argument to your test function which would be n. I'm going to try it now and tell you if it works.
You also didn't assign count in test(). I don't understand what you were trying to do with count in test I don't think those do anything
ok wait let me upload my most recent one
ok sorry some indentation issues...heres the most recent one, it just returns -5
ok still in test you are not giving it an argument therefore n is not assigned inside the function test(). Your argument should be test(n).
ok now it just returns -5 once...i guess thats an improvement
In your test function the body of your else statement should be even with "for a in range(0,n)" because the way yours is setup it will only check the first possible solution in stead of all solutions in (0,n) and would you rather me explain everything or post a fixed code.
can you please post a fixed code then if i have any questions ill ask you?
Yea one sec lemme do it really quick.
and i know some people use tuples or lists on this problem, thats not needed right?
Do you want to see it done with a list?
no thanks, i havent tried it yet so i'd rather attempt on my own but thanks for all the help!
so basically i just had to get rid of the else statement because it was causing it to check for only one value?
you had to add the argument to test which was test(n). I deleted the print n-5 in test there was no point to it. Your return n-5 should only be return n. I also deleted your n=0 its outside the function and isn't doing anything.
sorry I forgot to comment out the wrong stuff instead of deleting it.
its fine i understood it all, main thing was deleting the else statement...but why exactly do i need an arguement for test?
try it without the arguments you get a name error because functions have local variables. so unless you tell it to take an argument none of the variables you are already using will carry over. Therefor the n in cheese() will not moved to test() unless you tell it to by putting test(n).
Did that help?
yeah thanks
thanks btw im 16 so we are the young ones of this school lolz
Yeah, no problem and thats cool haha I'll be 16 in June.
Join our real-time social learning platform and learn together with your friends!