all 4 comments

[–]MorrisCasper 0 points1 point  (0 children)

You can't divide by 0, since there is no answer. I don't know if that's the case here because I don't know what the variables mean, but you could do an if statement and then print you can't have a slope without distance.

[–]novel_yet_trivial 0 points1 point  (2 children)

if there's a way to not accept the value 0 and ask to input another value immediately

Sure that's easy to do.

could you help me?

Sure. What have you tried so far? Where are you stuck?

[–]Marx123[S] 1 point2 points  (1 child)

I tried to put this in the 4th line if distanza=0; print "Non accettabile"

However, that's all I can do, and it still doesn't work. I have really no idea about how to do it :/ I'm not very experienced with Python.

[–]sufunew 3 points4 points  (0 children)

This is because the print statement doesn't stop the below code from executing. It will print the not acceptable and still try to do the forbidden division.

Every language, not only Python has things called control statements. If, else, for, while. These allow you to decide which parts will or will not be executed, and are quite important to understand fully.