Ask Question
19 February, 01:49

Write a recursive program that requests an answer to the question "Are we there yet?" using an input statement and terminates if the user answers 'yes', but executes a recursive call if the user answers anything else (do not use any loops in this program).

+4
Answers (1)
  1. 19 February, 04:35
    0
    def recursive_func ():

    x = input ("Are we there yet?")

    if x. casefold () = = 'Yes'. casefold ():

    return

    else:

    recursive_func ()

    recursive_func ()

    Explanation:

    We define the required function as recursive_func ().

    The first line takes user input. The user input is stored in variable x.

    The next line compares the user input to a string yes. The function executes the else block if the condition isn't met, that is a recursive call is executed.

    IF condition returns the function. The string in variable X is compared to a string 'Yes'. the casefold () is a string function that ignores the upper/lower cases when comparing two strings. (This is important because a string 'yes' is not the same yes a string 'Yes' or 'YES'. Two equal strings means their cases and length should match).
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write a recursive program that requests an answer to the question "Are we there yet?" using an input statement and terminates if the user ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers