0

I want to make the output to look like this:

******************
Enter your age: 
******************

But the input would appear in the middle of the strings. eg.

******************
Enter your age: 15
******************

Is it possible to get this done by using Python 2.7.12?

1
  • Looking back to my old questions, this was an attempt to make the cursor go back one line above, and the link from the accepted answer revealed that this may not be possible for different terminals. Commented Oct 15, 2019 at 15:35

2 Answers 2

1

Based on this answer, What can I use to go one line break back in a terminal in Python?, it is really terminal-dependent. I have tried on the console of Windows 10, and it seems that this is not possible.

However, it is possible to move the cursor one character before/after another on the same line using the escape character \b

Sign up to request clarification or add additional context in comments.

Comments

0

You could use:

age = 15
print "******************"
print "Enter your age: %s" % age
print "******************"

Either that, or:

age = 15
print "******************Enter your age: %s******************" % age

I'm guessing it's the first version, but your syntax of the question is wrong, the two options look the same.

2 Comments

what I mean was all of the strings are already printed but when the user type in, for example, 15, the number would appear in between those printed lines
So you want to be able to print a second line of '*'s after the input(text-wise)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.