<p>试图打印时,<code>stancount</code>变量超出范围。你知道吗</p>
<p>您可以将它作为参数传递到<code>print_mining_values()</code>函数中,并以这种方式打印它</p>
<p>所以<code>print_mining_values()</code>会变成:</p>
<pre><code>def view_mining_values(sCount, aCount, uCount):
print("\n Printing all of the variables now.")
print("\n Number of standard miners starting with: ")
print(sCount)
print("\n Number of advanced miners starting with: ")
print(aCount)
print("\n Number of ultra miners starting with: ")
print(uCount)
</code></pre>
<p>你的<code>min_count_set()</code>函数会变成:</p>
<pre><code>def min_count_set():
stancount = int(input("How many standard miners do you wish to start with? "))
if (stancount > 10000 or stancount < 0):
print("\n Please enter a valid number to start with. \n \n")
min_count_set()
else:
advcount= int(input("How many advanced miners do you wish to start with? "))
if (advcount > 10000 or advcount < 0):
print("\n Please enter a valid number to start with. \n \n")
min_count_set()
else:
ultrcount = int(input("How many ultra miners do you wish to start with? "))
if (ultrcount > 10000 or ultrcount < 0):
print("\n Please enter a valid number to start with. \n \n")
min_count_set()
else:
print("\n Returning you to the setup menu \n \n")
set_mining_values(stancount, advcount, ultrcount)
</code></pre>
<p>注意变量现在被传递到打印函数中。你知道吗</p>