Ex6 print(joke_evaluation.format(False))

Hi Everyone,

Looking at the code print(joke_evaluation.format(False)). I break the code and notice I did not define a variable name that is equivalent to False. It turns out Python3 accepted it and does not shows any errors. I’m googling on it and but In the meantime, can someone explain in KISS (Keep it super simple)


False is actually a valid value for that, so all you kind of did was just change hilarious to what hilarious stands for. Try putting in a name that doesn’t exist.

thanks Zed for explanation.

Hi, I am confused about the last second brackets of the line Joke_evaluation.
What is the use of {} ? . From output i can tell it is printing false. Without {}, false does not print.

I just could not get the idea how, {} is printing False. Can not find the relation. Will you please explain.

Hi @greenkernel

The curly brackets makes a ”container” for variables.

first = ”William”
last = ”Shakespeare”
print(f” My name is {first} {last}”)
1 Like

Like @ulfen69 says, except the {} is a special case that says “put the next thing here”. It’s positional, so that means the first one goes where the first {} is in the string.

1 Like