I want to write 2 functions. One function that takes input from a user and adds it to a list. The 2nd function takes the list returned from the 1st function and prints out each element separated by a space. I think I am close, but something isn't right. Typing -999 doesn't stop the loop, and I can't tell if I am calling the functions correctly...
Any ideas?
def listFunc():
num = 0
list1 = []
while num != -999:
x = int(input('Enter a number, -999 to quit: '))
list1.append(x)
return list1
def formatFunc(y):
final = str(y)
' '.join(final)
print(final)
formatFunc(listFunc())
num=0and don't update it inside the loop. If you were to straighten out the variable names betweennumandx, you would see a different result I suspect. Voting to close as typo.numinstead ofxwhich is the user input.num. Also' '.join(final)does not change anything unless you assign back tofinal.