Iterables and Iterators

  • + 0 comments

    just for reference

    from itertools import combinations num=int(input()) #taking n inputs letter=input().split()# taking letter input k=int(input()) #taking combinations input eg 2=ag combination=list(combinations(letter,k)) #using list() to get length combi_a=0 for i in combination: if "a" in i: combi_a+=1 #add one if a is found in i(combination) print(combi_a/len(combination))