Function call Return Challenge

Below is the code I have written.
Expecting “Clean.txt” in return but receiving “Clean” only.
Can someone help?

def openclose(filename):
print(“Filename =”,filename)
if filename:
print(“File Opened Successfully”,filename)
return filename

print(“Call OpenClose(filename)”)
print("Return File Name is ",filenamz)

You are returning “Clean.txt”, but you never change filenamz. Because you do not assign the returned value to any name, it is discarded and filenamz remains the same.

Thanks for guiding Sir.
I was thinking that i am returning filename which is Clean.txt.
And my passed/returning variable is filenamz. So was thinking that no need to re-assign.
Will do as you guided. Thanks.

It’s been long time since programming is left :), re-entering into.

Just wondering, when i m returning into “filenamz” and directly printing the same, why it’s not storing “Clean.txt”…

Because you are telling Python to discard it.

>>> filenamz = "Clean"
>>> def ret_file(filename):
...     return filename + ".txt"
>>> ret_file(filenamz)
>>> filenamz

The above is what you are doing. You see it is returning “Clean.txt”, but it is discarded.

>>> filenamz = ret_file(filenamz)
>>> filenamz

This is what you should do to get the expected outcome.

To get more feeling for names and what these mean in Python, see this video.