Does that work? Because in most programming languages each string would become truthy and that would evaluate to:
if what.lower() == True:
Does that work? Because in most programming languages each string would become truthy and that would evaluate to:
if what.lower() == True:
Yes. Saw someone talk about it on the Ask forum and everyone was surprised it actually worked lol.
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":
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
the bonus of this is that I can make my this code will make you mad Repl even worse >:)
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!
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.
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.
for print
specifically, you’d rather avoid the need to concatenate the strings (+
):
print("£", final_amount, sep="")