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?

dee cue
  • 983
  • 1
  • 7
  • 23
  • 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. – dee cue Oct 15 '19 at 15:35

2 Answers2

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

dee cue
  • 983
  • 1
  • 7
  • 23
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.

Ty Staszak
  • 115
  • 2
  • 11
  • 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 – dee cue Sep 14 '16 at 02:11
  • So you want to be able to print a second line of '*'s after the input(text-wise) – Ty Staszak Sep 18 '16 at 04:12