208k views
3 votes
Write function that ask for input from a user. Use this input as input for the countdown function that we wrote using the while loop. If the user types 'end', the program exits, otherwise it keeps going.

1 Answer

7 votes

Answer:

Written in Python:

def myfunction():

userinput = input("User input: ")

while(userinput != "end"):

countdown(userinput)

userinput = input("User input: ")

Step-by-step explanation:

This line defines the function

def myfunction():

This line prompts user for user input

userinput = input("User input: ")

The following while loop checks if userinput is not "end". It continues execution until user input "end"

while(userinput != "end"):

countdown(userinput) If yes, the input is passed to the countdown function for execution

This line prompts user for another user input

userinput = input("User input: ")

Please note the above code segment assumes that countdown() function has already been written and defined

User Bushed
by
6.9k points