擅长:python、mysql、java
<p>从原始输入判断,我猜您正在使用Python2。
将代码更正为:</p>
<pre><code>import random
print 'Hi, I will print out random intergers from a range you specify.\n'
#No need for parenthesis
begin=float(raw_input('Please enter the starting range. \n'))
end=float(raw_input('Please enter the end range. \n'))
rep=float(raw_input('Please enter how many times you cant to repeat the function. \n'))
# ERROR you forgot an extra parenthesis on the end of each of the last 3 lines.
def do():
print random.randint(begin, end)
count = 0
while count < rep:
do() # <- Parenthesis, and no need to print.
count = count + 1
print 'Thanks for using this program!\n' #No need for parenthesis
raw_input('press enter to continue')
</code></pre>
<p>还包括:</p>
<pre><code>count = 0
while count < rep:
do() # <- Parenthesis, and no need to print.
count = count + 1
</code></pre>
<p>可替换为:</p>
<pre><code>for count in range(rep):
do()
</code></pre>