I'm looking for a way to make the text that the user types in the console bold
input("Input your name: ")
If I type "John", I want it to show up as bold as I'm typing it, something like this
Input your name: John
I'm looking for a way to make the text that the user types in the console bold
input("Input your name: ")
If I type "John", I want it to show up as bold as I'm typing it, something like this
Input your name: John
They are called ANSI escape sequence. Basically you output some special bytes to control how the terminal text looks. Try this:
x = input('Name: \u001b[1m') # anything from here on will be BOLD
print('\u001b[0m', end='') # anything from here on will be normal
print('Your input is:', x)
\u001b[1m
tells the terminal to switch to bold text. \u001b[0m
tells it to reset.
This page gives a good introduction to ANSI escape sequence.
You can do the following with colorama:
from colorama import init,Style,Fore,Back
import os
os.system('cls')
def inputer(prompt) :
init()
print(Style.NORMAL+prompt + Style.BRIGHT+'',end="")
x = input()
return x
## -------------------------
inputer("Input your name: ")
and the output will be as follows:
Input your name: John
ref. : https://youtu.be/wYPh61tROiY