title: How do I make it so that when I input a string and not a float it will print out "please input a valid number"
body: <p>How can I show an error message &quot;please input a valid number&quot; if I enter a string which is not a float? Because when I input a string I will get an error:</p>
  <blockquote>
  <p>ValueError: could not convert string to float:</p>
  </blockquote>
  <p>My code:</p>
  <pre><code> if unknown == 'S':
    if units in ('si', 'Si'):  
      u = float(input(&quot;Enter the initial velocity in m/s :&quot;))
      v = float(input(&quot;Enter the acceleration in m/s : &quot;))
      t = float(input(&quot;Enter seconds : &quot;))
    else:
      u = float(input(&quot;Enter the initial velocity in yards/s :&quot;))
      v = float(input(&quot;Enter the acceleration in yards/s : &quot;))
      t = float(input(&quot;Enter the time take in s : &quot;))
  
      
    S = 0.5 * (u + v) * t
    print(&quot;S is &quot; , S)
  </code></pre>