filmov
tv
Global variable and Local variable with same name in python #shorts
![preview_player](https://i.ytimg.com/vi/TSKl0F_fZFI/maxresdefault.jpg)
Показать описание
In the above video, we used the same name x for both global variable and local variable. We get a different result when we print the same variable because the variable is declared in both scopes, i.e. the local scope inside foo() and global scope outside foo().
When we print the variable inside foo() it outputs local. This is called the local scope of the variable.
Similarly, when we print the variable outside the foo(), it outputs global. This is called the global scope of the variable.
#shorts #Shorts #python3 #local #global #legb #YoutubeShorts
When we print the variable inside foo() it outputs local. This is called the local scope of the variable.
Similarly, when we print the variable outside the foo(), it outputs global. This is called the global scope of the variable.
#shorts #Shorts #python3 #local #global #legb #YoutubeShorts