python program to Reverse String without using in-built function Python | interview question
Вставка
- Опубліковано 15 жов 2024
- Reverse String:
The reversing of a string is nothing but simply substituting the last element of a string to the 1st position of the string.
here in this video shows, without using Python inbuilt function reverse the string.
example for inbuilt function:
reverse()
slicing method
string is one of data type in Python
string are declared in Python with single quotation or double quotation ( ' ' or " " ).
please explain the code
n = "any string value"
x = "" # empty variable, which can store rev value
for i in n: # loop run length of string n
x = i + x # store characters 1 by 1 from end point.
print (x) # rev value