Iterables and Iterators

  • + 0 comments
    from itertools import combinations
    n = int(input())
    s = list(input().split(" "))
    k = int(input())
    count = 0
    for tup in combinations(s,k):
        if any(elem == 'a' for elem in tup):
            count += 1
    print(count / len(list(combinations(s,k))))