How to create global variable in Pyhton and use this variable inside the function? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
0

How to create global variable in Pyhton and use this variable inside the function?

global variable

16th Oct 2017, 12:13 PM
đĺđ░ĐüđŞđ╗Đî đąđ░đ╝Đâđ╗ĐĆđ║
đĺđ░ĐüđŞđ╗Đî đąđ░đ╝Đâđ╗ĐĆđ║ - avatar
2 Antworten
0
thank you
16th Oct 2017, 2:02 PM
đĺđ░ĐüđŞđ╗Đî đąđ░đ╝Đâđ╗ĐĆđ║
đĺđ░ĐüđŞđ╗Đî đąđ░đ╝Đâđ╗ĐĆđ║ - avatar
- 1
1 . any variable created outside any func. is a global by default... 2 . any variable declaired in any func. is a local variable...to use it/access it out side the func. or in other functions...u have to make it global.. example: a=5 def hello() : print(a) global b b=7 print(b) ## outside function; accessing b >>> 5 7
16th Oct 2017, 1:18 PM
sayan chandra
sayan chandra - avatar