If you have any questions, comments or issues with this project please post them here!
Hey, on Day4 colours were added as a bonus and somehow that particular part didnāt work out for me. On Day20, itās suggested we use different colours again ⦠and I tried and failed again. Unfortunately, the usually so very helpful solutions didnāt help because they donāt include the colour idea. I would love to see an example of code with colours - be it as a solution to Day4 or Day20 - if thatās possible!
Thank you, MattDESTROYER, very much for sharing your version! I forked (is that the verb?!) it and had a look at the colour part ⦠and it DID destroy me:) ⦠you did way more than a real beginner could have done on Day4 of this 100 Day course. Iāll put it aside for now and revisit it later when it (hopefully) looks less daunting than just now! Anyhow: Thank you! One day Iāll surely understand what you have done to make it look so smart ā¦
Itās true, Iām not a beginner, but I honestly donāt know much Python soā¦
Itās really not that complex, I just created a helper function to make it easier for me and to make the code a little cleaner. The tutorial tells you you can do print("\033[
< colour > m")
, then gives you a list of values for different colours. If you combine them, you can create this:
default = "\033[0m"
black = "\033[30m"
red = "\033[31m"
green = "\033[32m"
yellow = "\033[33m"
blue = "\033[34m"
purple = "\033[35m"
cyan = "\033[36m"
white = "\033[37m"
Basically, you print the colour you want to use, then the text you want to colour (but donāt forget to reset the colour to default if you want to stop using colours, because this will not automatically happen).
For example:
print(red + "Red", yellow + "Yellow", green + "Green", cyan + "Cyan", blue + "Blue", black + "Black", white + "White")
And hereās what that would look like:
Hope this helps
Anjalene, to expand on what MattDESTROYER explained to you with his example. If you didnāt have the helper function, you would just type in something like the following if this helps.
Example:
print(āThis is a \033[31mRed\033[0m word.ā)
The above example should print the word Red in red color. The first color change using the \033[31m changes the color before the word Red to the color red and then the color change after the word Red using the \033[0m changes the color back to the default color before the last of the string ending in āword.ā. Hope this helps.
Thank you, UlyTheHumble. I will revisit the colours in a couple of days with your help and MattDestroyerās. Iām sure I will manage now! Thanks again to both of you!
Thank you so much, MattDestroyer, for all your help! Iām sure I can do it now thanks to you (and UlyTheHumble)!
I canāt figure out how to use colored print I learned from day 4 of 100 days of code in python IDLE
hereās the code i learned
print(ā\033[32mā, āHelloā)
Hey @ParanormalCoder, welcome!
You can also use this method :
from termcolor import colored
print(colored("Hello","red"))
I personally like it more!
Thanks iāve been trying to figure that out for a while
code has been updated!
Do you think it will work outside the replit?
Feel like a proper storyteller with the custom storybook that I coded up !
https://replit.com/@JackAdem/Day-004-Project-4-Adventure-Simulator?v=1
#Replit100DaysOfCode #100DaysOfCode.
termcolor
is a Python package, so as long as it is installed this will work. Replit automatically installs packages for you so outside of Replit there might be more steps involved (also note the Replit console may look slightly different to whatever console your operating system has), but it will definitely still work.
(This is a note mostly for me but where others can read. This is mostly just to keep me going and motivated to finish the 100 Days Of Code.)
Day 4- Today was a lot more fun I would say with the coding part of things. We had built a store sort of where you can answer and see what will go on. I canāt wait to get into some things that I havenāt done before so I can learn from the challenge. I hope to be moving into the stuff I donāt know and I think that will start happening quite soon. I think at the pace the course is going I should get into that stuff very soon.
Extra Note:
Once again, I am quite worried as tomorrow marks the start of my first weekend while being on this challenge. Like I said in my last post on Day 3:
I hope I wonāt forget as I am having a lot of fun with this.
Question:
what does this error mean:
name = input("Hello! What is your name?: ")
car = input("Ok, " + name + " what is your favourite car?: ")
place = input("Ok," + name + " where would you drive in your ", car, "?: ")
hates = input("Ok, " + name + " what do you hate the most?: ")
car = input("Ok, " + name + " what is the name of your father?: ")
Repl link:
(https://replit.com/@BananaPi/day4100-days)
name = input("Hello! What is your name?: ")
car = input("Ok, " + name + " what is your favourite car?: ")
place = input("Ok," + name + " where would you drive in your ", car, "?: ")
hates = input("Ok, " + name + " what do you hate the most?: ")
car = input("Ok, " + name + " what is the name of your father?: ")
You forgot a + to concatenate strings.
Ok, thanks. But in the tutorial, it says you can use commas to do this as well.
number = input("Give me a number: ")
group = input("Give me a collective noun for a group of things: ")
thing = input("Give me the name of a weird or wacky thing: ")
print("No I don't think that", number, "is a", group, "of", thing,". That's just odd.")
(this is in day 3 of the 100 days of code)