# Function call Return Challenge

**URL:** <https://discuss.python.org/t/function-call-return-challenge/13394>\
**Category:** Python Help\
**Created:** [January 28, 2022, 12:03pm UTC](https://discuss.python.org/t/function-call-return-challenge/13394 "2022-01-28T12:03:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nitinmjoshi](https://avatars.discourse-cdn.com/v4/letter/n/e19b73/32.png) [@nitinmjoshi](https://discuss.python.org/u/nitinmjoshi)\
**Post date:** [January 28, 2022, 12:03pm UTC](https://discuss.python.org/t/function-call-return-challenge/13394/1 "2022-01-28T12:03:44Z")

</div>

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

def openclose(filename):  
filename=filename+".txt"  
print(“Filename =”,filename)  
filenameptr=open(filename,“w”);  
if filename:  
print(“File Opened Successfully”,filename)  
filenameptr.close()  
return filename

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

---

<div class="post-metadata">

**Author:** ![Mholscher](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/mholscher/32/15325_2.png) [@Mholscher](https://discuss.python.org/u/Mholscher)\
**Post date:** [January 28, 2022, 12:30pm UTC](https://discuss.python.org/t/function-call-return-challenge/13394/2 "2022-01-28T12:30:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![nitinmjoshi](https://avatars.discourse-cdn.com/v4/letter/n/e19b73/32.png) [@nitinmjoshi](https://discuss.python.org/u/nitinmjoshi)\
**Post date:** [January 28, 2022, 12:38pm UTC](https://discuss.python.org/t/function-call-return-challenge/13394/3 "2022-01-28T12:38:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![nitinmjoshi](https://avatars.discourse-cdn.com/v4/letter/n/e19b73/32.png) [@nitinmjoshi](https://discuss.python.org/u/nitinmjoshi)\
**Post date:** [January 28, 2022, 12:49pm UTC](https://discuss.python.org/t/function-call-return-challenge/13394/4 "2022-01-28T12:49:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Mholscher](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/mholscher/32/15325_2.png) [@Mholscher](https://discuss.python.org/u/Mholscher)\
**Post date:** [January 28, 2022, 12:59pm UTC](https://discuss.python.org/t/function-call-return-challenge/13394/5 "2022-01-28T12:59:49Z")

</div>

> [@nitinmjoshi](#):
>
> why it’s not storing “Clean.txt”…

Because you are telling Python _to discard it_.

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

```

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

```auto
>>> filenamz = ret_file(filenamz)
>>> filenamz
'Clean.txt'

```

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](https://nedbatchelder.com/text/names1.html).
