Day 010 - Project 10 : Extend your bill calculator

Does that work? Because in most programming languages each string would become truthy and that would evaluate to:

if what.lower() == True:
1 Like

Yes. Saw someone talk about it on the Ask forum and everyone was surprised it actually worked lol.

1 Like

I just tested it, it makes sense now, the first value in the parenthesis is truthy so the or statements are skipped and the parenthesis evaluates to the first string, in this case yes. Only the first value is compared, which means you’re actually just doing:

if what.lower() == "yes":
1 Like

I think i was the one surprised it worked because it is not actually since all you are doing is first the ORs in the () and then the ==, and as “yes” or “y” or “ye” is actually yes … all you do is ==“yes”


oh. bruh. I guess it doesn’t work lol. now I need to fix everywhere I used it :skull:

the bonus of this is that I can make my this code will make you mad Repl even worse >:)

1 Like

Oh noooooooooooooo … should have shut up

Hi, sorry if this is old hat, but I am just starting out on this course and I was wondering if you could give me a hint:

How do you add a currency symbol without a space straight in front of the final_amount?

hi @RobloxFoxxx you can use a + operator instead of a comma e.g.

print("This is your bill total £"+final_amount)

Hope this helps!

1 Like

Wouldn’t you have to cast final_amount to a string?

print("This is your bill total £" + str(final_amount))

Brilliant, thanks! In the end, I had to cast final_amount to a string.

1 Like

Whoops. You are absolutely correct. I’ll go sit in the corner.

This is what I get for teaching coding in Java for the last five weeks.

1 Like

for print specifically, you’d rather avoid the need to concatenate the strings (+):

print("£", final_amount, sep="")
1 Like