Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
colored input()
#1
Hello,

How would I colored input prompt? I know how to when printing but not input.

I got this so far.

from colorama import init
from termcolor import colored

init()

def computer_prompt():
    return (colored('Computer: ', 'green', 'on_blue'))
def user_prompt():
    return (colored('User: ', 'yellow', 'on_blue'))

print(computer_prompt()+'Please enter a word.')

word = input(user_prompt()+('?: '))

print(word)
You can see that 'Computer: ' returns with green text but how do I color the 'User: ' input?

I get the following error when running this code:

Error:
<-[44m<-[33m?: <-[0m?:
I thought it was as easy as creating a function like computer_prompt but I just couldn't get the result I was looking for.

Please help.

Thank You.
Reply


Messages In This Thread
colored input() - by Trianne - Oct-12-2018, 03:44 PM
RE: colored input() - by wavic - Oct-13-2018, 08:08 AM
RE: colored input() - by Trianne - Oct-15-2018, 06:31 PM
RE: colored input() - by wavic - Oct-15-2018, 06:50 PM
RE: colored input() - by nilamo - Oct-15-2018, 06:58 PM
RE: colored input() - by Trianne - Oct-15-2018, 07:34 PM
RE: colored input() - by wavic - Oct-15-2018, 07:50 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How do I classify colored images into 3 classes max22 0 1,166 Dec-04-2023, 10:33 PM
Last Post: max22
Question Colored text Alivegamer 3 4,095 Feb-28-2022, 02:43 AM
Last Post: BashBedlam
  fontforge Emoji encoding and colored glyphs pauf28 0 2,757 Dec-22-2020, 10:05 AM
Last Post: pauf28
  Error printing colored text julio2000 0 1,843 Feb-02-2020, 07:04 PM
Last Post: julio2000

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020