Python - Print multiple colors in one line Unicorn Meta Zoo #1: Why another podcast? Announcing the arrival of Valued Associate #679: Cesar Manara Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Calling an external command in PythonWhat are metaclasses in Python?Finding the index of an item given a list containing it in PythonWhat is the difference between Python's list methods append and extend?How can I safely create a nested directory in Python?How to print colored text in terminal in Python?Does Python have a ternary conditional operator?How to read a file line-by-line into a list?Does Python have a string 'contains' substring method?Catch multiple exceptions in one line (except block)
Suing a Police Officer Instead of the Police Department
My admission is revoked after accepting the admission offer
Israeli soda type drink
What is the ongoing value of the Kanban board to the developers as opposed to management
Align column where each cell has two decimals with siunitx
Book with legacy programming code on a space ship that the main character hacks to escape
Why does the Cisco show run command not show the full version, while the show version command does?
std::is_constructible on incomplete types
Are all CP/M-80 implementations binary compatible?
Is Bran literally the world's memory?
How would I use different systems of magic when they are capable of the same effects?
How to not starve gigantic beasts
Do I need to protect SFP ports and optics from dust/contaminants? If so, how?
"Whatever a Russian does, they end up making the Kalashnikov gun"? Are there any similar proverbs in English?
A strange hotel
Is accepting an invalid credit card number a security issue?
Arriving in Atlanta after US Preclearance in Dublin. Will I go through TSA security in Atlanta to transfer to a connecting flight?
Are these square matrices always diagonalisable?
Does the set of sets which are elements of every set exist?
Is there any hidden 'W' sound after 'comment' in : Comment est-elle?
Is a 5 watt UHF/VHF handheld considered QRP?
Password Generator in batch
How to open locks without disable device?
As an international instructor, should I openly talk about my accent?
Python - Print multiple colors in one line
Unicorn Meta Zoo #1: Why another podcast?
Announcing the arrival of Valued Associate #679: Cesar Manara
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!Calling an external command in PythonWhat are metaclasses in Python?Finding the index of an item given a list containing it in PythonWhat is the difference between Python's list methods append and extend?How can I safely create a nested directory in Python?How to print colored text in terminal in Python?Does Python have a ternary conditional operator?How to read a file line-by-line into a list?Does Python have a string 'contains' substring method?Catch multiple exceptions in one line (except block)
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I'm new to programming, so keep this in mind as you read my post, as I probably made a dumb mistake that I didn't realize. Basically, I was attempting to print the word "Rainbow," except that the R is red, the a is yellow, the i is green, etc. However, the following code I used to attempt to produce this output an error.
from termcolor import cprint
cprint("R", 'red' + "a", 'yellow', "i", 'green' + "n", 'blue' + "b", 'cyan' + "o", 'magenta' + "w", 'grey')
Error:
TypeError: cprint() takes from 1 to 4 positional arguments but 9 were given
My question is how can I produce my wanted output? Thanks in advance.
python python-3.x output
add a comment |
I'm new to programming, so keep this in mind as you read my post, as I probably made a dumb mistake that I didn't realize. Basically, I was attempting to print the word "Rainbow," except that the R is red, the a is yellow, the i is green, etc. However, the following code I used to attempt to produce this output an error.
from termcolor import cprint
cprint("R", 'red' + "a", 'yellow', "i", 'green' + "n", 'blue' + "b", 'cyan' + "o", 'magenta' + "w", 'grey')
Error:
TypeError: cprint() takes from 1 to 4 positional arguments but 9 were given
My question is how can I produce my wanted output? Thanks in advance.
python python-3.x output
"An error" is the worst of all errors since nobody can help you with that.
– Klaus D.
Mar 9 at 6:10
what is the error you see?
– shotgunner
Mar 9 at 6:11
Welcome to SO. Please get familiar with mcve it's the 4 commandments of asking a question here. In there it states: "It doesn't work" is not a problem statement. Tell us what the expected behavior should be. Tell us what the exact wording of the error message is, and which line of code is producing it. Please edit your question with the error message so we can help you!
– Jab
Mar 9 at 6:22
add a comment |
I'm new to programming, so keep this in mind as you read my post, as I probably made a dumb mistake that I didn't realize. Basically, I was attempting to print the word "Rainbow," except that the R is red, the a is yellow, the i is green, etc. However, the following code I used to attempt to produce this output an error.
from termcolor import cprint
cprint("R", 'red' + "a", 'yellow', "i", 'green' + "n", 'blue' + "b", 'cyan' + "o", 'magenta' + "w", 'grey')
Error:
TypeError: cprint() takes from 1 to 4 positional arguments but 9 were given
My question is how can I produce my wanted output? Thanks in advance.
python python-3.x output
I'm new to programming, so keep this in mind as you read my post, as I probably made a dumb mistake that I didn't realize. Basically, I was attempting to print the word "Rainbow," except that the R is red, the a is yellow, the i is green, etc. However, the following code I used to attempt to produce this output an error.
from termcolor import cprint
cprint("R", 'red' + "a", 'yellow', "i", 'green' + "n", 'blue' + "b", 'cyan' + "o", 'magenta' + "w", 'grey')
Error:
TypeError: cprint() takes from 1 to 4 positional arguments but 9 were given
My question is how can I produce my wanted output? Thanks in advance.
python python-3.x output
python python-3.x output
edited Mar 9 at 15:37
Jim Todd
944611
944611
asked Mar 9 at 6:05
thatonehaykthatonehayk
52
52
"An error" is the worst of all errors since nobody can help you with that.
– Klaus D.
Mar 9 at 6:10
what is the error you see?
– shotgunner
Mar 9 at 6:11
Welcome to SO. Please get familiar with mcve it's the 4 commandments of asking a question here. In there it states: "It doesn't work" is not a problem statement. Tell us what the expected behavior should be. Tell us what the exact wording of the error message is, and which line of code is producing it. Please edit your question with the error message so we can help you!
– Jab
Mar 9 at 6:22
add a comment |
"An error" is the worst of all errors since nobody can help you with that.
– Klaus D.
Mar 9 at 6:10
what is the error you see?
– shotgunner
Mar 9 at 6:11
Welcome to SO. Please get familiar with mcve it's the 4 commandments of asking a question here. In there it states: "It doesn't work" is not a problem statement. Tell us what the expected behavior should be. Tell us what the exact wording of the error message is, and which line of code is producing it. Please edit your question with the error message so we can help you!
– Jab
Mar 9 at 6:22
"An error" is the worst of all errors since nobody can help you with that.
– Klaus D.
Mar 9 at 6:10
"An error" is the worst of all errors since nobody can help you with that.
– Klaus D.
Mar 9 at 6:10
what is the error you see?
– shotgunner
Mar 9 at 6:11
what is the error you see?
– shotgunner
Mar 9 at 6:11
Welcome to SO. Please get familiar with mcve it's the 4 commandments of asking a question here. In there it states: "It doesn't work" is not a problem statement. Tell us what the expected behavior should be. Tell us what the exact wording of the error message is, and which line of code is producing it. Please edit your question with the error message so we can help you!
– Jab
Mar 9 at 6:22
Welcome to SO. Please get familiar with mcve it's the 4 commandments of asking a question here. In there it states: "It doesn't work" is not a problem statement. Tell us what the expected behavior should be. Tell us what the exact wording of the error message is, and which line of code is producing it. Please edit your question with the error message so we can help you!
– Jab
Mar 9 at 6:22
add a comment |
1 Answer
1
active
oldest
votes
You are probably searching for colored function in termcolor module.
from termcolor import colored
print(colored("R", 'red') ,colored( "a", 'yellow'),colored( "i", 'green' ),colored( "n", 'blue'),colored( "b", 'cyan' ),colored("o", 'magenta'),colored( "w", 'grey'))
This will print each of the letter as the color you mentioned.
You might possibly to prefer to access such functions via termcolor2. pypi.org/project/termcolor2 For example, PyCharm will autocomplete some identifiers for you.
– J_H
Mar 9 at 15:46
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55074520%2fpython-print-multiple-colors-in-one-line%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You are probably searching for colored function in termcolor module.
from termcolor import colored
print(colored("R", 'red') ,colored( "a", 'yellow'),colored( "i", 'green' ),colored( "n", 'blue'),colored( "b", 'cyan' ),colored("o", 'magenta'),colored( "w", 'grey'))
This will print each of the letter as the color you mentioned.
You might possibly to prefer to access such functions via termcolor2. pypi.org/project/termcolor2 For example, PyCharm will autocomplete some identifiers for you.
– J_H
Mar 9 at 15:46
add a comment |
You are probably searching for colored function in termcolor module.
from termcolor import colored
print(colored("R", 'red') ,colored( "a", 'yellow'),colored( "i", 'green' ),colored( "n", 'blue'),colored( "b", 'cyan' ),colored("o", 'magenta'),colored( "w", 'grey'))
This will print each of the letter as the color you mentioned.
You might possibly to prefer to access such functions via termcolor2. pypi.org/project/termcolor2 For example, PyCharm will autocomplete some identifiers for you.
– J_H
Mar 9 at 15:46
add a comment |
You are probably searching for colored function in termcolor module.
from termcolor import colored
print(colored("R", 'red') ,colored( "a", 'yellow'),colored( "i", 'green' ),colored( "n", 'blue'),colored( "b", 'cyan' ),colored("o", 'magenta'),colored( "w", 'grey'))
This will print each of the letter as the color you mentioned.
You are probably searching for colored function in termcolor module.
from termcolor import colored
print(colored("R", 'red') ,colored( "a", 'yellow'),colored( "i", 'green' ),colored( "n", 'blue'),colored( "b", 'cyan' ),colored("o", 'magenta'),colored( "w", 'grey'))
This will print each of the letter as the color you mentioned.
answered Mar 9 at 6:28
Jim ToddJim Todd
944611
944611
You might possibly to prefer to access such functions via termcolor2. pypi.org/project/termcolor2 For example, PyCharm will autocomplete some identifiers for you.
– J_H
Mar 9 at 15:46
add a comment |
You might possibly to prefer to access such functions via termcolor2. pypi.org/project/termcolor2 For example, PyCharm will autocomplete some identifiers for you.
– J_H
Mar 9 at 15:46
You might possibly to prefer to access such functions via termcolor2. pypi.org/project/termcolor2 For example, PyCharm will autocomplete some identifiers for you.
– J_H
Mar 9 at 15:46
You might possibly to prefer to access such functions via termcolor2. pypi.org/project/termcolor2 For example, PyCharm will autocomplete some identifiers for you.
– J_H
Mar 9 at 15:46
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55074520%2fpython-print-multiple-colors-in-one-line%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
"An error" is the worst of all errors since nobody can help you with that.
– Klaus D.
Mar 9 at 6:10
what is the error you see?
– shotgunner
Mar 9 at 6:11
Welcome to SO. Please get familiar with mcve it's the 4 commandments of asking a question here. In there it states: "It doesn't work" is not a problem statement. Tell us what the expected behavior should be. Tell us what the exact wording of the error message is, and which line of code is producing it. Please edit your question with the error message so we can help you!
– Jab
Mar 9 at 6:22