+ 4

What is the use of global variables in python

What is the use of global variables in python

11th Jun 2020, 10:00 AM
Vincent Lim
Vincent Lim - avatar
2 ответов
+ 5
You can maintain a value throughout the code and manipulate with it in particular independent blocks of code. Think of a game, where your character has an HP parameter. It can be influenced by many different situations and events, but has to be maintained globally, so that you know whether your character is dead or not :)
11th Jun 2020, 10:03 AM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 1
12th Jun 2020, 5:22 AM
Vincent Lim
Vincent Lim - avatar