Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 15 Online
OpenStudy (anonymous):

can I call a global variable inside a function? Eg to update a global list of answers to the number of times a function iterates

OpenStudy (anonymous):

Yes. If your variable is created outside the function, then inside the function type global name_of_variable like in this paste http://pastebin.com/JA6FJeAb

OpenStudy (anonymous):

ah so the "global" command is used to call a global variable inside a function

OpenStudy (anonymous):

It tells the interpreter that it should not create the variable in the local scope of that function. Rather, look outside the function, in the global scope, for the variable with this name.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Latest Questions
Arriyanalol: i need help
1 day ago 7 Replies 1 Medal
Arriyanalol: CONGRATS to me
1 day ago 8 Replies 2 Medals
Legomaster346: What colleges are good that are near Arab Alabama?
1 week ago 5 Replies 0 Medals
Arriyanalol: i need help
1 week ago 6 Replies 2 Medals
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!