0

Someone can help me with this code?

The code does not return ca correct value no matter what number i introduced. This is the code: https://code.sololearn.com/c5i0cVKY7yam/?ref=app

30th Sep 2018, 12:10 PM
Joita Vladut
Joita Vladut - avatar
2 odpowiedzi
+ 11
The code works fine. You are just not getting the output you want because integer division takes place on line 18. The variable f itself is of type integer. As a result, f will always be 0. Instead, you may declare f as float, and do something like: f = 1/float(x);
30th Sep 2018, 12:26 PM
Hatsy Rei
Hatsy Rei - avatar
+ 1
Thanks , for the answer, now the code works fine. Thank you.
30th Sep 2018, 1:26 PM
Joita Vladut
Joita Vladut - avatar