<p>我定义了一个函数,我可以调用它来将用户的输入存储为变量,
确保它是一个数字,并将该数字转换为整数,以便稍后在代码中使用公式。在</p>
<p>所以我们的想法是,当程序到达<strong>天</strong>时,它会提示用户输入<strong>getAnswer</strong>,然后启动函数,检查用户给出的答案,并将其转换为整数。与<strong>相同的工作</strong></p>
<pre><code>def getAnswer(a):
while True:
if a.isdecimal():
a = int()
break
print('Numbers only please...')
days = input(getAnswer)
worked = input(getAnswer)
</code></pre>
<p>这就是它最终的样子<;<a href="http://i.stack.imgur.com/BVLqV.jpg" rel="nofollow">function functionName at 0x013A1300</a>></p>