I want the following code to run the defined function, and save the output of the defined function in the specified variable "functionsOutput". And then, I want to replace the new lines in the variable with spaces.
But my code below isn't doing that. What am i doing wrong? The assignment of the function output to a variable is printing out the output. I don't want that. I want the output stored in the variable.
#!/usr/bin/python2.7
mylist = [ "hello", "you", "are", "so", "cool" ]
def printWithoutNewlines():
for objects in mylist:
objects = objects.replace('hello', "hi")
print objects
functionsOutput = printWithoutNewlines()
functionsOutput.replace('\n', ' ')