Tuesday, June 18, 2019

Finding the frequency of each element in a Tuple in Python

Code to find the frequency of each element in a Tuple in Python:
T=(1,2,3,1,1,5,5,6,1,5,5,6)
print("Tuple=",T)
for i in range(0,len(T)):
    if T[i] not in T[:i]:
        c=T[i:].count(T[i])
        print(T[i],"frequency=",c)

No comments:

Post a Comment

  Source Code for :   Displaying all possible fangs of a Vampire Number in Java import java.util.*; class Number {     public static void ma...