I want to display a string which is returned by a function in a Python script, without using print:
def myfunc(mystring):
return "Converting to lowercase :{0}".format(mystring.lower())
result=myfunc("LOWER")
result
But it doesn’t give an output. How can I get result to display without print?
Your code does print
'Converting to lowercase :lower'when run in an interactive session (usingpythonoripython).It does not, however, print anything if run as part of a script, since there is no implicit printing of expression results.
This is how it’s meant to be.
If you want to print something from a script, use
printorsys.stdout.write().