[Solved] Python questions about else and elseif [closed]


Yes off course! It will work like that but it’s only for this condition in which you have only one condition so the compiler checks whether it’s true or not but what if there’s more than one conditions ?? Also not using elif will allow the program to output the other print statement, but using elif or else if will allow to check the condition and give the output.

Here you’re simply using an if condition statement if it’s true it will give you output otherwise it will not go inside the if condition. For more conditions you have many options either do it in your way but using if statement Everytime will allow the compiler to go through every statement and by using if else or if-elif-else will reduce the time to compile the program.

So, using if statement each time will take so much time to compile.
Using else if reduces the no of comparisons.

I hope this helps ?

1

solved Python questions about else and elseif [closed]