 Python! Please, help! | SoloLearn: Learn to code for FREE!

+2

# Python! Please, help!

The sequence of Latin characters and spaces is given. A group of characters that is separated on one or both sides by spaces and does not contain spaces inside it is called a word. Change the order of the letters to reverse in those words that have the longest length.Count the number of such words

14 Answers

New Answer

+5

txt = input("print your text") or "hello my name is Alice" txt_list = txt.split(" ") maxLen = max(list(map(len, txt_list))) count_words= len(list(filter(lambda x: (len(x)==maxLen), txt_list))) result = " ".join([x[::-1] if len(x)==maxLen else x for x in txt_list]) print(result) print(f'count of max length words is {count_words}')

+3

Example: Input: hello my name is Alice Output: olleh my name is ecilA

+3

a = input("ENTER: ").split() b = max([len(x) for x in a]) for x in range(len(a)): if len(a[x]) == b: a[x] = a[x][::-1] [print(x + " ", end="") for x in a] print("\nCount of words = " + str(b)) #Hope this helps

+2

Alex Lollipop any example input or output you can show us!

0

First you find longest word in the sentence.... Aftet reverse the word..... txt = input().split() length = 0 for i in txt: if len(i) > length: length = len(i) for i in txt: if len(i) == length: qq = i break Longest word is the - qq Then reverse... P = reverse(qq) Print(len(p)) I think you will understand this....

0

Oh, it has some mistake..

0

May be..... Follow step by step

0

Reverse is not defined

0

Sorry bro, my bad... txt = input().split() #your code goes here length = 0 for i in txt: if len(i) > length: length = len(i) for i in txt: if len(i) == length: p = i break print(len(p[::-1]))

0

now it counts the number of characters

0

I think I'm screwed ahhahah

0

where is your code so i can help you with?