Hello everyone today I am going to talk about the if-else statement. This generally works like: if something is true do this else do this, , if else, what is if else, Python Problems, programming, java, software, PHP, C programming, programming languages, visual, Pascal, Perl, XML program, UNIX, cyber program, C++, HTML, CSS, Python syntax, software, what is computer, programming, programming languages, computer programming, what is coding, what is programming, contract programming, need a programmer, cyber program, tmbmnadim, Alpha Codist, python, Alpha Codist, blogger, Python problems to solve, pythopn free corse, get python corse for free, Learn Python for free
Hello everyone today I am going to talk about the if-else statement. This generally works like: if something is true do this else do this.
Example:
You have a list of fruits that contains Apple, Orange, Banana on your computer. Now you have to buy the first item. You want your computer to check the first item in the list if it is an Apple or an Orange or a Banana. The code for this is written below. The program checks if the first item in the list and compare it with "Orange" and returns true or false. If it is true then it runs the code inside it.
busket = ["Apple", "Orange", "Banana"]
if busket[0] == "Orange": # busket[0] checks the first item in the list and compares it with "Orange" and returns true or false
print("It is an Orange")
elif busket[0] == "Apple":
print("It is an Apple")
else:
print("It is a Banana")
COMMENTS