Just write:
print("User: "+ input(""))
Update:
if you want to store the input so just do this:
print("User: ", end='')
msg = input("")
the print() function puts "\n" at the end of the string, so by replacing "\n" with "" we prevent python to jump to the next line and the user could write after printed text, "User: ".
Update 2:
you can build a user interface for your program and it makes your work so easy. However, if you want to run your program on the console, the easiest way is to store all the printed strings in the console then clear the console each time the user inputs a msg
and then print stored strings. Now you have the msg which is not printed in the console, so you can do whatever you want with it and then print it as print('User: ' , msg)
.
to clear the console:
import os
clear = os.system('cls') #for Windows
clear = os.system('clear') #for Linux
You can write clear like clear = lambda: os.system('cls')
and use it like clear()
whenever you want. But it return 0 and print a '0' in your console.
a full example:
import os
def clear():
dummy_var = os.system('cls')
stored_string = [f'stored {i}' for i in range(10)]
for txt in stored_string:
print(txt)
msg = input("")
clear()
for txt in stored_string:
print(txt)
print('User: ', msg)
stored_string.append('User: ' + msg)
run this example and see the result.