<pre><code>magnitude = input("Enter the value of magnitude: ")
for mag in magnitude:
if float(mag) <= 1.9:
print(mag1)
elif float(mag) <= 2.9:
print(mag2)
elif float(mag) <= 3.9:
print(mag3)
</code></pre>
<p>如果我用小数点做任何输入,我就会得到这个错误</p>
<pre><code>Traceback (most recent call last): line 36, in effects
if float(mag) <= 1.9:
ValueError: could not convert string to float: '.'
</code></pre>
<p>我尝试在循环之前将原始的input语句转换为float,但它只会给我一个不同的错误。你知道吗</p>