We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Python
- Collections
- Word Order
- Discussions
Word Order
Word Order
+ 1 comment n = int(input()) arr = [] for i in range(n): arr.append(input()) K = (sorted(set(arr), key = arr.index )) count = [] for i in range(0,len(K)): count.append(0) for j in range(0,len(arr)): if(K[i] == arr[j]): count[i] = count[i] + 1 print(len(K)) print(*count, sep=" ")
+ 0 comments from collections import Counter n = int(input()) words_list = [input() for n in range(n)] words_count = Counter(words_list) print(len(words_count)) print(*words_count.values())
+ 0 comments from collections import Counter n=int(input()) l=[] for i in range(0,n): l.append(input()) x=Counter(l) #counter method will return the character and its no of occurance in dictionay print(len(x)) print(*x.values()) #unpaking dictionay values
+ 0 comments Easy to understand solution
n = int(input()) dictV={} lists = [] for i in range(n): lists.append(input()) for i in lists: if i in dictV: dictV[i]+=1 else: dictV[i]=1 output = list(dictV.values()) print(len(dictV)) print(' '.join(str(i) for i in output))
+ 0 comments Easy to understand solution
Enter your code here. Read input from STDIN. Print output to STDOUT
n = int(input())
dictV={} lists = [] for i in range(n): lists.append(input())
for i in lists: if i in dictV: dictV[i]+=1 else: dictV[i]=1 output = list(dictV.values()) print(len(dictV)) print(' '.join(str(i) for i in output))
Load more conversations
Sort 1354 Discussions, By:
Please Login in order to post a comment