write a program to accept a string. Display the string in reverse order.
Input: Computer is fun.
Output: Fun is computer.
Answers
Answered by
10
s = input("enter string: ").split()
reversed_s = s[::-1]
first_word_arr = list(reversed_s[0])
del first_word_arr[-1]
first_word_arr[0] = first_word_arr[0].upper()
last_word_arr = list(reversed_s[-1])
last_word_arr[0] = last_word_arr[0].lower()
last_word_arr.append(".")
new_s_arr = [
"".join(first_word_arr),
"".join(reversed_s[1]),
"".join(last_word_arr)
]
print(" ".join(new_s_arr))
Similar questions
Business Studies,
9 months ago
Math,
9 months ago
Political Science,
1 year ago
Political Science,
1 year ago
Physics,
1 year ago