Skip to content

Tag: if-statement

Is there a better way to write my if statement?

I have a function that checks if multiple conditions are fulfilled before performing an operation. The code below shows all conditions that must be fulfilled. This code works perfectly as is. However, is there a better way of writing my if statements? Something about the look of it just feels wrong, feels ver…

Using exception for invalid entry

I am trying to use exceptions in my assignment to catch an error when a user input invalid entry. I tried using the if else statement to catch but whenever running the program it will skipped pass my exception even when I input invalid entry. Do any of you have any idea where I am wrong in the code? PS: