[Python] Python: Print string in reverse

Discussão em 'Python' iniciado por Stack, Abril 26, 2025.

  1. Stack

    Stack Membro Participativo

    Write a program that takes in a line of text as input, and outputs that line of text in reverse. The program repeats, ending when the user enters "Done", "done", or "d" for the line of text.

    Ex: If the input is:

    Hello there
    Hey
    done


    then the output is:

    ereht olleH
    yeH


    I have already the code like this. I don't understand what I have done wrong. Please help.

    word = str(input())
    the_no_word = ['Done', 'done', 'd']
    while word == "Done" and word == "done" and word == "d":
    break
    print(word[-1::-1])

    Continue reading...

Compartilhe esta Página