for any of you having doubt like me that why do we create a custom class , well not all errors fall in value error , index error etc. like the dob case above , so we created a new one
class Error(Exception): pass class emailException(Error): pass class customgeneric(Error): pass email= str(input("Enter your email ")) try: if '@' in email: print("Email is valid") else: raise emailException except emailException: print("Your email needs to have @") This is an example of a email validation with exception handling.
Hi krish, I am currently on this video. and when i use even year (say 2022 or 2024) then the try block is skipping and only except is running even when the age is in valid range. any help please?
Dude because these are greater than 2021...hence your age will be negative...and they will go in the exception case...any age except btween 20 and 30 will go to the exception case
You can use While loop. Like this.. class DateOfBirthError(Exception): def __init__(self,error = ""): self.doberror = error def __str__(self): return self.doberror while True: age = int(input("Enter your age: ")) try: if age >= 18 and age
Hello I am a working Mechanical Engineer. Wanted to be a Data Scientist. I have started learning Python. What should be my strategy for next 6 to 8 months ?
sir , can you please help in this topic " Predictive analytics for social networks" . it is my final year project. please sir it my request to help me on this topic that what can i do in this..
for any of you having doubt like me that why do we create a custom class , well not all errors fall in value error , index error etc. like the dob case above , so we created a new one
I am a beginner and I say your content are awesome. The way you explain is super brain friendly. ❤❤
Sir you made a mistake in if condition while checking the age , "&" must be replaced by "and".
class Error(Exception):
pass
class emailException(Error):
pass
class customgeneric(Error):
pass
email= str(input("Enter your email "))
try:
if '@' in email:
print("Email is valid")
else:
raise emailException
except emailException:
print("Your email needs to have @")
This is an example of a email validation with exception handling.
Erron man check it
For @ in email .you can use..not if
Thanku so much Krish sir
Hi krish, I am currently on this video. and when i use even year (say 2022 or 2024) then the try block is skipping and only except is running even when the age is in valid range. any help please?
Dude because these are greater than 2021...hence your age will be negative...and they will go in the exception case...any age except btween 20 and 30 will go to the exception case
its because he's used bitwise operator, instead use 'and'... it will work fine
Sir, how can we give correct input value again by knowing the exception error of the past entry.
You can use While loop. Like this..
class DateOfBirthError(Exception):
def __init__(self,error = ""):
self.doberror = error
def __str__(self):
return self.doberror
while True:
age = int(input("Enter your age: "))
try:
if age >= 18 and age
Hey Kris why you make the class of Error and dobException ?? This can be done directly done in try and except
Thanks Krish
Can you please put a video of using big data in image recognition of cnn or any other project :- i want to learn using big data in ML
Is there a way to return an empty list if you get a certain exception?
Hello I am a working Mechanical Engineer.
Wanted to be a Data Scientist.
I have started learning Python.
What should be my strategy for next 6 to 8 months ?
Go back to Mechanical Engineering.
@@princeofexane Why so? Can you explain?
It's not a good idea to use bitwise operator & instead use 'and'.
sir please make video on object detection, bert, vgg16
i never understood this easy.
💜💜💜💜💜
So Nice 💘💘💘💘💘💘
sir , can you please help in this topic " Predictive analytics for social networks" . it is my final year project. please sir it my request to help me on this topic that what can i do in this..
Good info
It should be "and " rather than "&"
thank you so much for your help!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
was stuck badly due to this error
Check why 2020 born are getting the error ?
❤✨