+ 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

1st Mar 2021, 7:48 PM
Alex Lollipop
14 Respuestas
+ 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}')
2nd Mar 2021, 9:42 PM
Andrew Smith
Andrew Smith - avatar
+ 3
Example: Input: hello my name is Alice Output: olleh my name is ecilA
2nd Mar 2021, 7:26 AM
Alex Lollipop
+ 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
3rd Mar 2021, 4:41 AM
Calvin Thomas
Calvin Thomas - avatar
+ 2
Alex Lollipop any example input or output you can show us!
1st Mar 2021, 8:17 PM
Abhay
Abhay - avatar
+ 2
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]))
1st Mar 2021, 8:18 PM
Naveen Rathore
Naveen Rathore - avatar
+ 1
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....
1st Mar 2021, 8:02 PM
Naveen Rathore
Naveen Rathore - avatar
+ 1
May be..... Follow step by step
1st Mar 2021, 8:14 PM
Naveen Rathore
Naveen Rathore - avatar
0
Oh, it has some mistake..
1st Mar 2021, 8:11 PM
Alex Lollipop
0
Reverse is not defined
1st Mar 2021, 8:14 PM
Alex Lollipop
0
now it counts the number of characters
1st Mar 2021, 8:21 PM
Alex Lollipop
0
I think I'm screwed ahhahah
1st Mar 2021, 8:22 PM
Alex Lollipop
0
😭
1st Mar 2021, 8:32 PM
Alex Lollipop
0
where is your code so i can help you with?
1st Mar 2021, 11:21 PM
iTech
iTech - avatar
0
❤️
3rd Mar 2021, 5:14 AM
Alex Lollipop