Python else keyword

ইনস্ট্যান্স

If x is greater than 5, print "YES", otherwise print "NO":

x = 3
if x > 5:
  print("YES")
else:
  print("NO")

ইনস্ট্যান্স চালু করুন

অর্থাৎ এবং ব্যবহার

The else keyword is used in conditional statements (if statements), it decides what to do when the condition is False.

The else keyword can also be used in the try...except code block, see the following example.

আরও ইনস্ট্যান্স

ইনস্ট্যান্স

In try ... except block, use the else keyword to define the handling method when no error is raised:

x = 5
try:
  x > 10
except:
  print("Something went wrong")
else:
  print("The 'Try' code was executed without raising any errors!")

ইনস্ট্যান্স চালু করুন

সংশ্লিষ্ট পাতা

if কীভাবে

elif কীভাবে

আমাদের Python কনডিশনাল টিউটোরিয়াল থেকে আরও বিষয় শিখুন