Raising custom errors in Python | Python Tutorial - Day #38

preview_player
Показать описание
Python is one of the most demanded programming languages in the job market. Surprisingly, it is equally easy to learn and master Python. This python tutorial for absolute beginners in Hindi series will focus on teaching you python concepts from the ground up.

python, C, C++, Java, JavaScript and Other Cheetsheets [++]:

►Learn in One Video[++]:

►Complete course [playlist]:

Follow Me On Social Media
Comment "#HarryBhai" if you read this 😉😉
Рекомендации по теме
Комментарии
Автор

This python course is helpful than all of those courses for paid!
Jabardast Harry Bhai!

jaideepawari
Автор

a = input("Enter any value between 5 and 9. Write 'quit' to quit:")
def myfuc():
if a=="quit":
print("program quitted")
else:
if(int(a)<5 or int(a)>9):
raise ValueError("Value should be between 5 and 9")
else:
print(a)
myfuc()

transylvanian
Автор

a = input("Enter the value between 5 and 9 : ")

if(a == "quite"):
print("Thank You")
elif(int(a)<5 or int(a)>9):
raise ValueError("The given item is invalid")
print("Thank You\nHave a Great Day")

aitanuja
Автор

a = input("Enter the value butween 5 and 9: ")

if (a == "quit"):
print("ohk")
elif (int(a) < 5 or int(a) > 9):
raise ValueError("The number should be between 5 and 9")

Prachi-sche
Автор

print("here we make errors by ownself".upper())
k1=input("enter the num between 5 and 9, write quite\n")
if int(k1)>5 or int(k1)<9:
print("no error everything is fine")
if int(k1)<5 or int(k1)>9:
raise ValueError("wrong")
if k1=="quite":
print("no error")
raise ValueError("don't use other str")

#love you harry

ghosttttttt
Автор

a= input("Enter a word")
class CustomError(Exception):
print("This is custom error")
if(a=="quit"):
print ("This word is \'quit\' ")
else:
raise CustomError("Word is unmatch")

coderistan
Автор

a = input("Enter any value between 5 and 9: ")
try:
if (int(a)<5 or int(a)>9):
raise ValueError("Value should be between 5 and 9")

except:
if a == str(a) and a !="quit":
raise ValueError("Value should be between 5 and 9")

print("code ended successfuly")

educationedition
Автор

a = input("enter the word : ")
if(a == "quit"):
print("You are good to go")
else:
raise SyntaxError("What are u doing")


by far the easiest one that i have done in this course not a regular commentator but this is the simple code that i have done

narayanISlive
Автор

In this video lecture, we learnt about the raising custom errors using raise keyword. Sometimes, we want to impose hard and fast regulations so, we can use customer errors if something violates those regulations so, that it does not create any problem later in the program execution and that error can be handled at that point of time only. In the previous videos, we learnt about how to handle errors using exception handling with try, except and finally blocks. We can also make our custom error classes using any base case error with our defined set of rules to raise that error whenever it violates those rules.

khemchand
Автор

a=input("Enter the value beetween 0 and 9 or quit for exit - ")
string=str(a)
for i in range(0, 10):
if a=="quit":
break
elif a!= "quit":
a=int(a)
if (a<0 or a>9):
raise ValueError("the Value should be in 0 to 9")
else:
print(a)

Автор

Quick Quizz Question ->
User = input("Enter The Value Between 5 And 9 : ")
try:
if (User == "Quit"):
print("Better Luck Next Time!")
else:
if (int(User)>= 5 and int(User) <= 9):
print(f"Congrulations! Your Entered Number {User} Is Between 5 And 9")
print("Good Job!")
elif (int(User) <= 4 or int(User) >= 10):
raise ValueError("Error : Inavlid Input (Value Should Be In 5 And 9)")
except ValueError as e:
print(e)

Thanks, Harry Bhai This Course IS Very Good.

kaushikrajit
Автор

a=input('Enter a number between 5 and 9: ')
if (a=='quit'):
exit()
elif a.isalpha():
print('Enter an integer value')
elif ((int(a)<5) or (int(a)>9) ):
raise ValueError('Entered value is not in between 5 or 9')
elif((int(a)>=5) or (int(a)<=9) ):
print ('Thank you for you input')

ChandniSingh-js
Автор

print("<--- Quick Quiz Solution ---> \n")
i = input("Write Here : ")
if i == "quit":
print("Successfully Quit")
else:
if (int(i) < 10 or int(i) > 20):
raise ValueError("Value should be between 10 and 20")

THANK YOU FOR THIS AMAZING QUIZ 😍😍😄😄 ❤❤

CodingHood
Автор

Here it is Sir:

def run():
user_input = input("Enter Value Between 5 and 9: ")
try:
if(user_input=='quite'):
print('I am quite')
elif(5>int(user_input)<9):
print('5>user_input)>9')
raise ValueError("Value must be 5>user_input)>9")
except:
pass

run()

abdullahbinshahzad
Автор

a = input("Enter a number between 5 and 20: ")
if a == 'quit':
print("Program broken!")
elif int(a)<5 or int(a)>20:
raise ValueError("The number should be greater than 5 and less than 20!")
else:
for i in range(1, 11):

adi.py-dev
Автор

a=input("Enter value : ")
if a== "quit":
print("Executed")
elif a!="quit":
raise ValueError ("U enter wrong value")

md.taahaabakhshi
Автор

a = input("Kindly enter an integral value between 5 and 10: ")

if a == "quit":
print("\nNo problem. Thanks for you time.")
else:
if (int(a)>9 or int(a)<6):
raise ValueError("Please enter a value within the desired range.")

raghavkapoor
Автор

num1=input("Enter the number between 5 to 8 :")

print("Quit Program")
elif num1.isdigit():
if (int(num1) < 5 or int(num1) > 8):
raise ValueError("Please enter number between 5 to 8")
else:
print("You have entered correct number")
else:
print("Please enter number between 5 to 8")

gurukrupalive
Автор

a = input("Enter num: ")

try:
if (int(a) < 0 or int (a)>5):
raise ValueError("Enter valid input!")
except:
if (a!="quit"):
raise ValueError("Enter valid input!")
print("End")

I'm late but tried my code and sucessfully executed

argos
Автор

a = input("Enter a number between 5 and 9 - ")

def hi():
try:
if int(a)<5 or int(a)>9:
return 1
except:
if a.lower() == 'quit':
print("Okay")
exit()

x=hi()
if x==1:
raise ValueError("Galat hai kuch")
else:
print("Fine")


SIMPLE AND EASY CODE

adityasudan