diff --git a/Algorithms/String/StringReverse/strRev.py b/Algorithms/String/StringReverse/strRev.py index 05ce5dee..cec66638 100644 --- a/Algorithms/String/StringReverse/strRev.py +++ b/Algorithms/String/StringReverse/strRev.py @@ -25,4 +25,19 @@ x=a[::-1] s=s.replace(a,x) -print(s) \ No newline at end of file +print(s) + +#Method 3 +def reverse(s): + str = "" + for i in s: + str = i + str + return str + +s = "programming is fun" + +print ("The original string is : ",end="") +print (s) + +print ("The reversed string(using loops) is : ",end="") +print (reverse(s))