New course! Every coder should learn Generative AI!
Try a free lesson+ 9
I think u can use three different approaches for this. But the most efficient one is you can use float () function while taking input and use try and catch block.
I have used int () in one of my codes. You can usr float () in same way.
https://code.sololearn.com/c3k6oegzfs79/?ref=app