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

How to fix it

Always, I have problems with the "global"; Anyone please help me to fix it: https://code.sololearn.com/ct5EooiU86bf/?ref=app

8th Aug 2018, 2:24 PM
Sousou
Sousou - avatar
1 Answer
0
global statement not define global variable instantion, only inform metod than you can use this existed global variable internaly. https://docs.python.org/3/reference/simple_stmts.html#the-global-statement So before call global variable you must define it outside method eg. in first line of your code: minnumb = maxnumb = lves = numb = 0 # line 1 Then some global variables are not described in the method, so you must add it. def program1(): global lves #line 4 def computer(): global numb #line 43 I tested it for input 0, 0, 40 ... and it works.
4th Dec 2018, 11:33 AM
zemiak