Please help me to use python to write this code and this pro

Please help me to use python to write this code, and this problem have a examle code, please only give me correct code, thanks.

Solution

def reverse_string(a_string):
n = len(a_string)
newStr = \"\"
for i in range(n-1, 0, -1):
ch = a_string[i]
newStr = newStr + ch
return newStr;


s = \"abcdef\"
print reverse_string(s);

Output:

fedcba

Please help me to use python to write this code, and this problem have a examle code, please only give me correct code, thanks.Solutiondef reverse_string(a_stri

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site