Day 004 - Project 4 : Adventure Simulator

Thanks i’ve been trying to figure that out for a while :grinning:

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 :open_book:!

https://replit.com/@JackAdem/Day-004-Project-4-Adventure-Simulator?v=1

#Replit100DaysOfCode #100DaysOfCode.

1 Like

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.

2 Likes

(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.

1 Like

https://replit.com/@BananaPi/Day-4-of-100-days-of-code?v=1

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.

1 Like

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)

hi, that’s only for print. input is different, the syntax is input(str), you can’t pass multiple arguments.

You need to do input("Ok," + name + " where would you drive in your " + car + "?")

6 Likes

main.py - day4_100 days - Replit

Hi @jtshort73, your Repl seems to run fine. Do you need help with anything?

So I’m on Day 4 of the Python 100 days of Code. I’m learning about color - specifically, I’m learning how to highlight particular words in color. However, I’m having trouble with highlighting the phrase I want (“our final battle begins!”) in the color red and not simply the rest of the text (“shouts the evil…”

Question: How do I highlight a portion of a text rather than the rest of it?

Here is the relevant portion of my code that I have so far:

print("\033[31m", "'our final battle begins!'", "\033[31m",  "shouts the evil..."

so instead of this you need to reset it. so use "\033[0m"

3 Likes

So I reset it, replacing what I had with

\033[0m

but when I changed it back to the color I wanted, it still didn’t work - the rest of the script/text turned red instead of just the portion I wanted.

When using color codes like such, the most recent update to color will be used for ALL outputs, not just one. Let me show you an example:

print("\033[31mHello!")
print("Hi!")

# Both outputs with be RED!

To fix this, you need to reset it with "\033[0m" like @QwertyQwerty88 said.

print("\033[31mHello!") # This text is red
print("\033[0mHi!") # This text is normal
2 Likes

So I figured it out.

Use the red color code before the particular text, and after the text use a white color code. (Maybe that’s what “resetting” means).

1 Like

that works, but bob and I said to use the “reset” color code, which is \033[0m

kinda, yeah.

1 Like

Ok that works. Thank you