Sunday, 23 January 2022

Write a python script to find the repeated items of a tuple

Slip 8 Q 1

CODE :

import collections

tuplex = 2,4,5,6,2,3,4,4,7,5,6,7,1

dictx=collections.defaultdict(int)
for x in tuplex:
    dictx[x]+=1
for x in sorted(dictx,key=dictx.get):
    if dictx[x]>1:
        print('%d repeted %d times'%(x,dictx[x]))

OUTPUT :




No comments:

Post a Comment

Write a Java program to display given extension files from a specific directory on server machine.

 DOWNLOAD     SLIP14Q2 /** * STEPS TO RUN CODE * Step 01 compile the code * Step 02 run the code * Step 03 give a file directory locatio...