How to put text after input field in python?

In python, if I wanted someone to enter the loan amount in dollars, I could encode something like this:

# Loan amount
L = float(input("Enter the loan amount: $"))

But what if I want, say, an interest rate that represents interest. If I encoded:

# Interest rate
I = float(input("Enter the interest rate: "))

How can I get the percent sign,%, to display after input?

+4
source share
1 answer

You need to control the cursor of the terminal.

After the user enters the input and presses the input, the cursor moves to the next line.

You need to move the cursor one line, then move it to the end of this line, type%, and then move the cursor back to a new line.

You can do this using the terminal escape sequence.

http://code.activestate.com/recipes/475116-using-terminfo-for-portable-color-output-cursor-co/

0

Source: https://habr.com/ru/post/1621197/


All Articles