Answer to Question #248956 in Python for kaavya

Question #248956

More distinct letters

you are given a list of strings, write a program to print the string with the maximum number of distinct letters. If there are more than one such strings, print the string which comes first in alphabetical order. Note: consider upper and lower case letters are different.

Input: The input is a single line containing the strings separated by a space.

Output: The output should be a single line containing the string with maximum distinct characters.

Explanation:

In the example, the given list of strings are raju , plays , golf. The word plays has the maximum number of distinct letters. So the output should be plays.


1
Expert's answer
2021-10-10T01:48:28-0400
lst = input().split()
llst = [len(set(x)) for x in lst]
print(lst[llst.index(max(llst))])

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS