CBSE Class 11 Computer Science
Question 15 of 21
String Manipulation — Question 3
Back to all questions 3
Question Question 3
Write a program which reverses a string and stores the reversed string in a new string.
Solution
str = input("Enter the string: ")
newStr = ""
for ch in str :
newStr = ch + newStr
print(newStr)Output
Enter the string: computer studies
seiduts retupmoc
str
=
input
(
"Enter the string: "
)
newStr
=
""
for
ch
in
str
:
newStr
=
ch
+
newStr
print
(
newStr
)
Output
Enter the string: computer studies
seiduts retupmoc