6th May 2021, 5:13 AM
Akash Prasad
Akash Prasad - avatar
6 Antworten
+ 5
See it's showing an error because u haven't defined 👉🏻(a). So let us take👉🏻 (a=24) Now u code will become as: a=24 def func(a): print(a) a+=1 print(a) print(a) func(7)
6th May 2021, 5:39 AM
Kǟrɨsɦmǟ ❥
Kǟrɨsɦmǟ ❥ - avatar
+ 4
'a' is a local variable means access to 'a' is limited to the scope where it was declared. Here scope of 'a' is the function . you can only access 'a' within the function. Trying to access it in outside of function giving you error on line 6
6th May 2021, 5:15 AM
TOLUENE
TOLUENE - avatar
+ 1
I tried inside still it shows error
6th May 2021, 5:25 AM
Akash Prasad
Akash Prasad - avatar
+ 1
Akash Prasad you have to create another variable outside function named 'a' . https://code.sololearn.com/cLAukOluKbyJ/?ref=app
6th May 2021, 5:40 AM
TOLUENE
TOLUENE - avatar
0
Global variable 'a' is not defined.
6th May 2021, 5:54 AM
Tomas Konecny
0
def func(a): print(a) a+=1 print(a) func(7) a is not a global variable
6th May 2021, 3:46 PM
syed fahad
syed fahad - avatar