I've tried using python's itertools to implement how to divide 10 students into teams of 5 each, but it doesn't work.

You can answer with print (len (L)/2). However, I tried to implement it by putting conditions in the comprehension, but it doesn't work though it may be a problem of my mathematical knowledge.

Corresponding source code
import itertools
L = [x for x in itertools.combinations ('ABCDEFGHIJ', r = 5)]
print (len (L))
What I tried Supplementary information (FW/tool version, etc.)
  • Answer # 1

    You want the number of streets, right?

    import math
    n = len ('ABCDEFGHIJ')
    count = math.factorial (n) // math.factorial (n -5) // math.factorial (5)
    print (count)
    # 252

  • Answer # 2

    You also have the option of using the scipy library

    from scipy.special import comb
    print (comb (N = 10, k = 5, exact = True))
    # 252

  • Answer # 3

    Even if you don't use comprehension forcibly

    len (list (itertools.combinations ('ABCDEFGHIJ', r = 5))) // 2

    Isn't it okay?