Write a program to print least frequent character in a string


Topic: Write a program to print least frequent character in a string

Solution

str1="watch the match"
all_freq = {} 
for i in str1: 
    if i in all_freq: 
        all_freq[i] += 1
    else: 
        all_freq[i] = 1
res = min(all_freq, key = all_freq.get)
print("Minimum of all characters is: " + str(res))



List all Python Programs