Variable location | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Variable location

Does the place of variable matter? for instance I always get confused where I should place the variable inside or outside the function? and befor or after print stetment?

1st Dec 2022, 12:48 AM
Mohamad Karou
Mohamad Karou - avatar
1 Answer
+ 3
variables inside a function can accessed only from inside the function, if put them outside then you can access them from more functions. To print a variable it need to created first so you always must set the variable you want to print and after call print function
1st Dec 2022, 1:45 AM
Giannis
Giannis - avatar