Professional Documents
Culture Documents
Programs On LIST
Programs On LIST
d = dict()
for key in string:
if key not in d:
d[key] = 1
else:
d[key] += 1
return d
print most_frequent('aabbbc')
Returning:
# list of numbers
list1 = [10, 20, 4, 45, 99]
Output:
smallest element is: 4
------------------------------------------------------------------------------------------------------------------------------------
# list of numbers
list1 = [10, 20, 4, 45, 99]
Output:
smallest element is: 4
------------------------------------------------------------------------------------------------------------------------------------
Find minimum list element for a user defined list
# Python program to find smallest
# number in a list
# list of numbers
list1 = [10, 21, 4, 45, 66, 93, 1]
even_count, odd_count = 0, 0
# checking condition
if num % 2 == 0:
even_count += 1
else:
odd_count += 1
------------------------------------------------------------------------------------------------------------------------------------
Function to print the characters
# of the given String in decreasing
# order of their frequencies