206k views
4 votes
Write a function named joinStrings() that keeps asking the user for words and joins them together. Each word should start with an uppercase letter and the rest of letters in the word should be lowercase. All the words should be separated by a space. When the user decides to stop, return the joined string

1 Answer

7 votes

Answer:

* The code is in Python

def joinStrings():

join = ""

while True:

str = input("Enter a word or Q to stop: ")

if str == "Q":

break

else:

join = join + " " + str

return join

print(joinStrings())

Step-by-step explanation:

Create a function called joinStrings

Initialize join variable to hold the strings that will be combined

Create a while loop that stops when user enters "Q". Otherwise, ask the user for a new string and join it to the join variable with a space

When the loop is done, return the join

Call the function and print the result

User Kap
by
5.5k points