reverse a string in python

Posted by Paidboom - 8 months ago

reverse a string in python : Python reverse a string Program

my_data_desc = "welcome to our paython tutorials" [::-1]
print(my_data_desc)
#using Simple function
def getReverseData(str):
    return str[::-1]
result = getReverseData("welcome to our paython tutorials")
print(result);    
#using reversed
def getReverseData1(string):
    string = "".join(reversed(string))
    return string
result1 = getReverseData1("welcome to our paython tutorials")
print(result1); 
#using Len
def getReverseData2(s):
    if len(s) == 0:
        return s
    else:
        return getReverseData2(s[1:]) + s[0]
result2 = getReverseData2("welcome to our paython tutorials")
print(result2);