Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

What is the way to add a text after user input while user adding it in the input? In Python

I would like to make ask the user for any data and put a text after the user input in the execution like below

Number of Persons = input("How many persons?")

Console: ((the Screen to be in same step user adding the answer:))

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

And How many persons? 5 Persons

>Solution :

From How to print at the same line of an input?

That will display How many persons? 1234 persons after pressing enter

text = "How many persons? "
nb_person = int(input(text))
print(f"\33[1A\33[{len(text) + len(str(nb_person))}C persons")
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading