Generation

generate functionTue, 07 Feb 2023

Write a Python function that will query words to form the 'query' list via 'input' until the user writes 'end'. If the user writes 'end', the function will store all the words in comma-separated list format in the 'query' variable and terminate the function.

def words(): query = [] while True: word = input("Enter word: ") if word == "end": print("Ending") break else: query.append(word) print(" ".join(query)) words()

Questions about programming?Chat with your personal AI assistant