For loop input ValueError

Hello folks

How can I fix ValueError in for loop? I would like to take input from the user.
Any help really appreciated.


Generally it’s easier to help when code is not on image.

As it can be seen, everything is good if input is an actually number. Troubles start when input value is not a number. You can either make sure the input value is something that can be converted to a float, or use the try/except statement.

1 Like

Well the go-to strategy for this is to include a try-except block. It will check if the included code can be executed without error.
Now you just gotta include some logic to ensure you get all the inputs you want.

Thanks for your advice.