looping through possible combinations of McNuggets packs of 6,9 and 20
Brian Victor
homeusenet4 at brianhv.org
Thu Aug 12 15:00:17 EDT 2010
Baba wrote:
> def can_buy(n_nuggets):
[snip]
> can_buy(55)
>
> as you can see i am trying to loop through all combinations of values
> bewtween 1 and n_nuggets and when the equation resolves it should
> return True, else it should return False.
>
> I was hoping that when i then call my function and ask it to test a
> value nothing happens. What is wrong? My syntax? My semantic? Both?
You're calling the function, but you're not doing anything with the
result. If you use "print can_buy(55)" you'll see the result on the
console. Presumably you'll actually want to use it in an if statement.
--
Brian
More information about the Python-list
mailing list