I need to make a code that doesn’t give me an error, I want a print to try again for example.
I learn in other topics, but I don’t understand anything about that.
I have this code:
def conversor(anosluz):
try:
km = float(anosluz * (9.459 * 10**12))
return km
except Exception, e:
print 'Ooops! O valor que inseriste nao e o correcto, tenta de novo.', e
if __name__=='__main__':
anosluz = input('Insira a distancia em anos luz: ')
resultado = conversor(anosluz)
print resultado
Divide your code into input/output and calculation: