How can I show an error message "please input a valid number" if I enter a string which is not a float? Because when I input a string I will get an error:
ValueError: could not convert string to float:
My code:
if unknown == 'S':
if units in ('si', 'Si'):
u = float(input("Enter the initial velocity in m/s :"))
v = float(input("Enter the acceleration in m/s : "))
t = float(input("Enter seconds : "))
else:
u = float(input("Enter the initial velocity in yards/s :"))
v = float(input("Enter the acceleration in yards/s : "))
t = float(input("Enter the time take in s : "))
S = 0.5 * (u + v) * t
print("S is " , S)