Q:

How can I change the cursor position of the user input in input() function in Python?

While using the input() function I want to take or receive a string from the user to a variable. So is it possible to input inside square brackets instead of plain text? For example;
a = input("-->")

this shows the output like this:
-->

but instead can I have the output like this:
--> [ _ ]

and take the input inside the square bracket. (_ represents the cursor.)

A:

Manipulating the cursor position when you call input() requires a hack with ANSI escape sequences. (See @chepner's answer.) To do what you want more correctly, you need to use a library that can manipulate the terminal, such as curses.

