2.Write a program to print a string in reverse without using built in methods?
This program reverses a given string without using any built-in methods.
Iterate through the string from the last character to the first character.
Append each character to a new string to reverse the o...read more
We can reverse a string using string slice operation
Str[::-1]
s=input("enter a string")
rev=""
for i in range(len(s)):
rev=s[i]+rev
print(rev)
def reverse(s):
return s[::-1]
str = 'hello world'
print(reverse(str))
def reverse_string(n):
for i in n:
reverse = n[::-1]
return reverse
n= "string"
prrint(reverse_string(n))
>>> Original_string = "this is a string"
>>> string=""
>>> for j in range(len(Original_string)):
j=j+1
a = (Original_string[-j])
string = string + a
>>>print(string )
Output: gnirts a si siht
OR
...read moreTop Accenture Python Developer interview questions & answers
Popular interview questions of Python Developer
Top HR questions asked in Accenture Python Developer
Reviews
Interviews
Salaries
Users/Month