Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

In Python , why do we use the elif ? and what is it?

In Python , why do we use the elif ? and what is it ?
I was learning about the else if commands and stumbled upon the elif and confused about it

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

It sounds as if you are familiar with an "Else if" statement. An "Elif" statement is the "Else if" version of python.

Take the following Java code:

if(1 < 2) {
  System.out.println("if statement");
} else if(3 > 4) {
  System.out.println("else if statement");
}

Would turn into the following Python code:

if 1 < 2:
  print("if statement")
elif 3 > 4:
  print("else if statement")
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading