def reverse(value)The string formatting functions of Ruby caught my interest, but I haven't checked if any equivalents exist in Python.
if value.length > 1 then
value[value.length-1] + reverse(value[0,value.length-1])
else
value[0]
end
end
irb> "#{reverse 'Hello, World!'}"
=> "!dlroW ,olleH"
No comments:
Post a Comment