Ask Question
27 September, 13:45

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).

+3
Answers (1)
  1. 27 September, 17:05
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers