Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Yes,you should take a look at this question <a href="https://stackoverflow.com/questions/423379/using-global-variables-in-a-function-other-than-the-one-that-created-them">Using global variables in a function other than the one that created them</a></p> <p>Briefly speaking,if it is only reading from a name, and the name doesn't exist locally, it will try to look up the name in any containing scopes.That's what happens to <code>temp</code>,which will be found in the global scope.But with <code>hhh</code>,you do writing,which will make Python believe that <code>hhh</code> is a local variable. </p> <p>And another thing,but more important,it is not recomended using <code>global</code>.You could invoke <code>actualcrawl()</code> in <code>start()</code>,and pass in <code>hhh,temp</code>,which is the way most people do.</p> <p>EDIT</p> <p>It is simple:</p> <pre><code>import random,os def start(): level=1 temp=' +-!' hhh='[X' os.system('CLS') actualcrawl(temp,hhh) def actualcrawl(temp,hhh): print (temp) for a in range(2,128): hhh=hhh+temp[random.randrange(1,8)] hhh=hhh[:79]+'&gt;'+hhh[80:] for i in range(1,3): a=random.randrange(3,8) b=random.randrange(6,15) hhh=hhh[:16*a+b-1]+'='+hhh[16*a+b:] for i in range(1,9): print (hhh[16*i-16:16*i]) </code></pre> <p>I don't know what language you use before Python,but you really don't need to declare a variable like in C/C++.Because when you assign to a variable, you are just binding the name to an object.See this <a href="https://stackoverflow.com/questions/13530998/python-variables-are-pointers">python variables are pointers?</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload