Iterables and Iterators

  • + 0 comments

    n = int(input()) # Length of the list letters = input().split() # List of letters k = int(input()) # Number of indices to select

    comb = list(combinations(letters, k)) favorable = sum(1 for group in comb if 'a' in group) probability = favorable / len(comb) print(f"{probability:.3f}")