How do I put an if and else loop in Python?
Python: Python is a popular programming language. It was created by Guido van Rossum, and released in 1991.
It is used for:
- web development (server-side),
- software development,
- mathematics,
- system scripting
if condition: We are using if condition for checking the given condition is true or not,
elif: The elif keyword says the previous condition was not true.
else: The else condition is running only when the if condition false.
Program:
- 1. a = 20
- 2. b = 10
- 3. if b > a:
- 4. print("b is greater than a")
- 5. elif a == b:
- 6. print("a is equal to b")
- 7. else:
- 8. print("a is greater than b")
Comments
Post a Comment