'Write a program that takes in a input and reverse the users output?

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 written most the program but I'm struggling with defining the user_string.

user_string = str(input())

while True:
    user_string = str(input())
    if user_string == 'Done' or mystring == 'done' or mystring == 'd':
        break
    print(user_string[::-1])


Solution 1:[1]

Not sure what mystring is supposed to do, as it just suddenly appears without any clear purpose.

However making judgement from the given code you should try:

# this line seems redundant, remove it. --> user_string = str(input())

while True:
    user_string = input() # str() not needed as input() returns a String by default.
    if user_string.lower() in {'done', 'd'}:
        break
    print(user_string[::-1])

Solution 2:[2]

In you if condition you have to compare user_string with Done, d or done instead of the variable mystring . Here is how it should be

#user_string = str(input()) you do not need this 

while True:
    user_string = str(input())
    if user_string == 'Done' or user_string == 'done' or user_string == 'd':
        break
    print(user_string[::-1])

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Bialomazur
Solution 2 ibadia