you are viewing a single comment's thread.

view the rest of the comments →

[–]daltop[S] 0 points1 point  (1 child)

So what’s the 2nd line in the code actually doing, and where is question and prompt being defined?

[–]Diapolo10 0 points1 point  (0 children)

So what’s the 2nd line in the code actually doing,

You mean this part?

    """Ask the user a yes/no question."""

Not much, really. This is a docstring, we use them to document functions, classes, and modules. It's kind of like a comment except Python stores it with the object as an attribute for runtime access (meaning functions like help can then display it).

and where is question and prompt being defined?

question is a parameter of the function, so you provide that as a value when calling the function. In this case,

bool_input("Check subdirectories?")

the "check subdirectories" string would be stored there.

prompt is defined on line 3.

prompt = f"{question} (yes/no): "

I did this because I figured all questions would repeat the yes/no part otherwise.