Computer Science, asked by divyanshthakur2k, 11 months ago


Name a
function that lets us print on the same line​

Answers

Answered by rairohitraj7
0

Answer:

made me brainliest

Explanation:

def function(s):

return s + 't'

item = input('Enter a sentence: ')

while item != '':

split = item.split()

for word in split:

new_item = function(word)

print(new_item)

item = input('Enter a sentence: ')

When a user types in 'A short sentence', the function should do something with it and it should be printed on the same line. Let's say that function adds 't' to the end of each word, so the output should be

At shortt sentencet

However, at the moment the output is:

At

shortt

sentencet

How can I print the result on the same line easily? Or should I make a new string so

new_string = ''

new_string = new_string + new_item

and it is iterated and at the end I print new_string?

Similar questions