Hey Guys, So I have an assignment regarding finding the most letters used in a word. For some reason I can't seem to make it work as the output that I get is based on First Letter. The def function for
This is my Code.
Nah Nevermind Got it. The
max_char_count I got from stack overflow if I'm not mistaken. Any help will be appreciated.This is my Code.
global str1
def main():
str1 = input("Enter Your Message: ")
print ("The Lenght of Your Message is:", len(str1),)
print (max_char_count(str1))
def max_char_count(str1):
max_char = ''
max_count = 0
for char in (str1):
count = str1.count(char)
if count > max_count:
max_count = count
max_char = char
return max_char
main()This is my output.Output:Enter Your Message: dsdss
The Lenght of Your Message is: 5
d
>>> ================================ RESTART ================================
>>>
Enter Your Message: saaa
The Lenght of Your Message is: 4
sOriginal Def function. I just add the .upper()def max_char_count(string):
max_char = ''
max_count = 0
for char in set(string):
count = string.count(char)
if count > max_count:
max_count = count
max_char = char
return max_char
print(max_char_count('eeFAGAAJeEff'.upper()))The Output:Output:>>>
E
>>> Nah Nevermind Got it. The
return is a space ahead. I don't know how to delete this thread.
