Combination Function Help

Mark Lawrence breamoreboy at yahoo.co.uk
Thu Feb 13 00:15:09 CET 2014


On 12/02/2014 22:59, kjakupak at gmail.com wrote:
> def choices(n, k):
>      if k == 1:
>          return n
>      if n == k:
>          return 1
>      if k == 0:
>          return 1
>      return choices(n - 1, k) + choices(n - 1, k - 1)
>
> comb = choices(n, k)
> print comb
>
> print ("Total number of ways of choosing %d out of %d courses: " % (n, k))
> n = int(input("Number of courses you like: "))
> k = int(input("Number of courses you can register for: "))
>
> Still isn't working though..
>

Please be precise, "still isn't working" tells us nothing.

-- 
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.

Mark Lawrence

---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com





More information about the Python-list mailing list