How to do error handling where it will only be possible to insert numbers?

Asked

Viewed 21 times

0

inserir a descrição da imagem aqui

import math

print('Insira comprimento do Lado \"C\":')

lado_c = float(input())

print('Insira comprimento do Lado \"B\":')

lado_b = float(input())

hipotenusa = math.hypot(lado_c, lado_b)

print('-------------------------------')

print(f'Lado A =  {round(hipotenusa,3)}')

y = math.atan(lado_c / lado_b)
y = math.degrees(y)
x = 90 - y

print('')

print('Angulo X = ', round(x, 2))

print('')

print('Angulo Y = ', round(y, 2))
  • 1

    Making lado_c = float(input()) it will only accept numbers, otherwise it will give error.

  • I would like to treat this error, like this: 'Type only numbers'. The problem is I don’t know how to do it.

  • You will see it here: https://answall.com/q/244764/5878

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.