user input that shows user what he gives input for in python

One way to achieve this is by using f-strings (formatted strings) in Python. You can use an f-string to print the user's input along with a message that alerts the user to what they are inputting.

Here is an example code that demonstrates this:

main.py
# prompt the user for input
name = input("Please enter your name: ")

# print out the user's input along with a message
print(f"You entered {name}.")
150 chars
6 lines

In the code above, we first prompt the user for their input by using the input() function. We pass in a message as an argument that tells the user what to enter.

Then, using an f-string, we print out the user's input along with a message. The curly braces {} are used inside the string to identify where the variable name should be inserted. The f before the string tells Python to treat the string as a formatted string.

When the code is run, it will prompt the user to enter their name. Once the user inputs their name, the code will print out a message that says "You entered [name].", where [name] is replaced with the actual input provided by the user.

gistlibby LogSnag