Lesson 28 of 34
try / except: Errors সামলানো
9 min 30 XP
ব্যবহারকারী সংখ্যার বদলে অক্ষর লিখলে int() ValueError দেয় এবং প্রোগ্রাম থেমে যায়। ঝুঁকিপূর্ণ কোড try-তে রাখুন এবং সমস্যা except-এ সামলান।
Example: edit me and press Run
Output Loading Python (first time takes a few seconds)
Press Run to see the result here.প্রতিটি ধরনের error-এর জন্য আলাদা except লিখুন। finally অংশ সবসময় চলে।
Example: edit me and press Run
Output Loading Python (first time takes a few seconds)
Press Run to see the result here.নিজের error-ও তুলতে পারেন: raise ValueError("Age cannot be negative")