Reversing the words of the sentence
Write a program that receives a sentence and reverses each word and re -print the sentence without changing the order of words.
Input: Hello Amir ...
Olleh RIMA ...
Write a program that receives a sentence and reverses each word and re -print the sentence without changing the order of words.
Input: Hello Amir ...
Olleh RIMA ...
let msg = 'error' alert(msg)This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error' alert(msg)This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error' alert(msg)This answer is only visible to premium members
This answer is only visible to premium members
r = input("matn: ") h = "" for i in r: # Reverse the string h = i + h print(h)
a=[] b=(input('str:')) for i in b: a.append(i) for j in reversed(a): print(j,end="")
def reverse_words_in_sentence(sentence): words = sentence.split() reversed_words = [word[::-1] for word in words] return ' '.join(reversed_words) sentence = input("Enter a sentence: ") print(reverse_words_in_sentence(sentence))
def reverse_words(sentence): """این تابع کلمات یک جمله را برعکس میکند.""" # Divide the sentence into words words = sentence.split() # Reversing any word reversed_words = [word[::-1] for word in words] # Converting the list of inverse words into a sentence reversed_sentence = ' '.join(reversed_words) return reversed_sentence def main(): # Receive a sentence from the user sentence = input("لطفاً یک جمله وارد کنید: ") # Reversing the words and printing the result result = reverse_words(sentence) print(result) # Implementation of the program main()
en_string = input ('str: ') rev = [i[::-1] for i in en_string.split()] rev_u = " ".join(rev) print (f'{rev_u} --> {en_string}')
def reverse_words(sentence): # Separate sentence words words = sentence.split() # Reversing any word and saving in the new list reversed_words = [word[::-1] for word in words] # Combining the inverse words into a sentence reversed_sentence = " ".join(reversed_words) return reversed_sentence
def str(name): s=name.split() r=map(lambda t:t[::-1],s) return ''.join(r) text=input("text: ") print(str(text))
Submitting answers is currently unavailable.
Write a program that receives a number from the input and checks whether the number is segmented to 5. Tips: The numeric is on 5 segments that remain the remaining 5 zero
Write a function that receives a string and returns the number of letters: To solve this question, you should not use ready-made functions for example: get_len ('code-bezan.ir') # 13
Write a function that receives a text and returns the first 100 characters with "..." if the text is longer than 100 characters. Otherwise it will restore the whole text unchanged.
Write a program that receives a student's lessons and the number of each unit (receiving the score and the number of units until the number is 0).
برای استفاده از این بخش باید وارد حساب کاربریت بشی
ورود/ثبت نام If you don’t understand the exercise or can’t solve it for any reason, that’s completely
normal—don’t worry 😊
Try checking out easier exercises and reviewing different answers
submitted by others. Gradually, you can move on to more challenging exercises. Also, your answer
might be correct even if it’s different from others.