Reverse. How can i get a better output?


I have done this with a list and using the join function it works and that is ok but there is a way to remove the spaces between characters?
Or can i do this using a different method too?

def reverse (text):
    bottomup = []
    while c>0:
        print text[c],
    return "".join(bottomup)

text = raw_input("Inserire parola da tradurre in reverse:")
reverse (text)


what is currently shown in the output is cause by this print:

print text[c],

if you want to see the reversed string, i would simply recommend to print what the function returns, you do this by adding a print statement to the function call:

print reverse (text)


Oh thanks! Now is totally better xD


yes, .join() made sure the string was perfectly joined, you just needed to print it :wink:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.