# Modify variables in a function

**URL:** https://forum.makecode.com/t/modify-variables-in-a-function/7688
**Category:** micro:bit
**Created:** [April 28, 2021, 5:56pm UTC](https://forum.makecode.com/t/modify-variables-in-a-function/7688 "2021-04-28T17:56:44Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![MINTGenie](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/mintgenie/32/1052_2.png) [@MINTGenie](https://forum.makecode.com/u/MINTGenie)
#### Post date: [April 28, 2021, 5:56pm UTC](https://forum.makecode.com/t/modify-variables-in-a-function/7688/1 "2021-04-28T17:56:44Z")

</div>

Why is it not possible to modify the value of a variable in a function when using blocks but works when using python? If i call the function with say 2 arguments (numbers) and in the function definition, how do I set/change the value of the function parameters?

---

<div class="post-metadata">

### Author: ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)
#### Post date: [April 28, 2021, 7:32pm UTC](https://forum.makecode.com/t/modify-variables-in-a-function/7688/2 "2021-04-28T19:32:49Z")

</div>

What I did is create a global variable that is the same name as the parameter you want to modify and then used the blocks to modify the global variable but since there is a parameter with the same name as the global variable in a function, it gets “shadowed” by the local variable so, in reality, you are actually modifying the local variable. I’ve tried this and it seems to work.
