How to make input text bold in console?

Question:

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

Asked By: Hardy

||

Answers:

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.

Answered By: Nick Lee

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

Answered By: Yashar Sajadi
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.