Computer Science, asked by Jackshaw, 18 days ago

Write a Python program which reverse a string and store the reversed string in a new string​

Answers

Answered by ayush070501
1

Answer:

Python is the easiest and most popular language in the world. Here i am giving the answer in which i am taking a input from the user . I hope the answer will help you. Get it in the explanation section.

Explanation:

S = str(input())

k =int(input())

x = ''

while len(S)>0:

   if len(S)>3:

       i = S[0:k]

       y = i[::-1]

       S = S[k:]

   else:

       i = S[0:]

       y = i[::-1]

       S = ''

   x = x + y

print(x)

Please like this answer if you find it useful so that it can motivate me in  the future

Similar questions