Python Programming Tutorial – 28 – You are the only Exception

Facebook – https://www.facebook.com/TheNewBoston-464114846956315/
GitHub – https://github.com/buckyroberts
Google+ – https://plus.google.com/+BuckyRoberts
LinkedIn – https://www.linkedin.com/in/buckyroberts
reddit – https://www.reddit.com/r/thenewboston/
Support – https://www.patreon.com/thenewboston
thenewboston – https://thenewboston.com/
Twitter – https://twitter.com/bucky_roberts

Comments

LtL Lorenzo says:

when i type in a non integer for this, it doesnt ask for a favorite number again it gives me a nameerror

Erggo the Magnificent says:

I had to use “NameError” instead of “ValueError”, I’m guessing because I’m using Python 2.7.13.

Thanks for great tutorial, Bucky.

Anton Penchev says:

Please stop humming before every sentence

Faris Amirmudin says:

why do we need to put try?

Minzkraut says:

is there a way to print out the exception? like print(str(except)

Anand Patel says:

Getting NameError
what to do???

Neddih Lous says:

that’s very useful

Smidgen says:

has the zeroDivisionError stopped working in 3.6? doesnt seem to work for me

orcun koral işeri says:

using python 3.6 and getting this error:
SyntaxError: unexpected EOF while parsing

How can i solve ?

Eyal Pery says:

King,

MainManPhillis says:

Could someone explain the purpose of the “while True:” before the try statement.  It seems like we would never exit the loop because we never explicitly return false. I’m coming from java so its also weird that there is no object attached with “True”.

idan says:

why you don’t teach about codes you write…. what is a int, input, and except when we learn about them ??

Walking Taco15 says:

while True:
try:
number = int(input(“what’s your fav number?”))
print(“Wow, “, number, ” Is my favorite number too!”)
break
except ValueError:
print(“Please enter a valid number.”)

3icepwn says:

What’s the difference between NameError and ValueError. I get NameError instead of ValueError.

Martin Baltuhin says:

Dude, you helped me with Android, now you are helping me with python :) god or whatever you believe in, bless you!

Venkatesh Chary says:

i am new to python coding ,
can you tell me how to raise custom exception in python?

Tatrasiel7 says:

I think Thenewboston is one of the best channels on YouTube… I have learned a lot here  and There is no knowledge that is not power! – Mortal combat 

Bhati ManishKumar says:

hi i am getting
UserWarning: No parser was explicitly specified, so I’m using the best available HTML parser for this system (“lxml”). This usually isn’t a problem, but if you run this code on another system, or in a different virtual environment, it may use a different parser and behave differently.

The code that caused this warning is on line 20 of the file test.py. To get rid of this warning, change code that looks like this:

BeautifulSoup(YOUR_MARKUP})

to this:

BeautifulSoup(YOUR_MARKUP, “lxml”)

markup_type=markup_type))

Jatin Lalwani says:

Dude just change your theme to intelliJ

Mozer says:

Good!

The friendly AT-AT says:

The title tells me Bucky likes Paramoe.

Ahmed Salem says:

how to add the “true” Module?
((name ‘true’ is not defined))

TNTSquid says:

Serious question: I’m pretty curious on whether the fucking NullPointerException that always waste my a lot of time exist in Python as well?

Zwerggoldhamster says:

I like to ask the user for their first input before I enter the while loop. Then for example I try to get the integer, and if I have a ValueError, I can already ask for an input in the exception, then repeat the loop and try to convert to a an int, etc.

Sean Brown says:

Yep your cool. Bucky! You are literally my favorite programming teacher ever.

the3lusive says:

Why can’t I use boolean here when dealing with the except keyword ?

RandomlyRight says:

Thanks for helping! I wonderd why my code did not work: had to change to an integer.
Anyway awsome  tutorial as always!

JiaMing Lim says:

hahah, i had to learn this the hard way xD

Shaurya Kapoor says:

I don’t get the answer in decimals. Why is that?

Shaurya Kapoor says:

If I divide by a number higher than 18 then I get a zero, why is that?

Mehmet Ece says:

while True:
try:
number = int(input(“What’s your fav number boss?n”))
print(2/number)
break
except ZeroDivisionError:
print(“Zero isn’t a number”)
except SyntaxError:
print(“Make sure you enter a number.”)
except NameError:
print(“Wrong once more, please try again.”)
except TypeError:
print(“You’re not very good at this, are you? try again.”)
except:
break
finally:
print(“loop complete”)

Terry DeSimone says:

I have a question, running the source from this video.. I was surprised when the return value came back as a “FLOAT”, when you specifically “casted” the input value as a “INT”.. 3 entered / 6.0 returned..
are INT’s & FLOATS interchangeable in Python 3.6? (having a PHP background, they are not the same).. but i just seen it with my own eyes.. lol

Bipul Kumar Sharma says:

can you please upload a video on the topic – using debugger in pycharm….
i kind of don’t know how to use a debugger

Faisal AlKusayer says:

but if you remove the (int) it would fix it, you could type words and numbers

OmeglaWaffles101 says:

you are the one that made me wanted to program more in python because you make it sound so interesting so i linked you in my channel (OmeglaWaffles101) and i subscribed

JP Gangwar says:

sir if we gievn value
like mama = str(input(“what is your number?n”)
print(mama)
then output will come int and string value both r accepted why sir

IGR Gaming says:

10/10 Title

sithandra lee says:

I did’t get a zerodivisional error when i multiplied 0/18
while True:
try:
number = int(input(“what is your fav colorn”))
print(18/number)
break
except: ValueError
print(“enter a valid number. “)
——————————————————————————————-
C:Python34python.exe “C:/Users/Chinese Cyber Army/PycharmProjects/untitled/First.py”
what is your fav color
0
enter a valid number.
what is your fav color

Musquet I. says:

1:24 … durrrr… Tom Dwan … anybody?

Altaf Neva says:

I dont know why but I like the channel display picture so much..!!!

Write a comment

*

Human Verification: In order to verify that you are a human and not a spam bot, please enter the answer into the following box below based on the instructions contained in the graphic.


Do you like our videos?
Do you want to see more like that?

Please click below to support us on Facebook!

Send this to a friend

▷ Other ReviewsVehicles▷ Show Cars▷ Motorbikes▷ Scooters▷ Bicycles▷ Rims & Tires▷ Luxury BoatsFashion▷ Sunglasses▷ Luxury Watches▷ Luxury Purses▷ Jeans Wear▷ High Heels▷ Kinis Swimwear▷ Perfumes▷ Jewellery▷ Cosmetics▷ Shaving Helpers▷ Fashion HatsFooding▷ Chef Club▷ Fooding Helpers▷ Coktails & LiquorsSports▷ Sport Shoes▷ Fitness & Detox▷ Golf Gear▷ Racquets▷ Hiking & Trek Gear▷ Diving Equipment▷ Ski Gear▷ Snowboards▷ Surf Boards▷ Rollers & SkatesEntertainment▷ DIY Guides▷ Zik Instruments▷ Published Books▷ Music Albums▷ Cine Movies▷ Trading Helpers▷ Make Money▷ Fishing Equipment▷ Paintball Supplies▷ Trading Card Games▷ Telescopes▷ Knives▷ VapesHigh Tech▷ Flat Screens▷ Tech Devices▷ Camera Lenses▷ Audio HiFi▷ Printers▷ USB Devices▷ PC Hardware▷ Network Gear▷ Cloud Servers▷ Software Helpers▷ Programmer Helpers▷ Mobile Apps▷ Hearing AidsHome▷ Home Furniture▷ Home Appliances▷ Tools Workshop▷ Beddings▷ Floor Layings▷ Barbecues▷ Aquarium Gear▷ Safe Boxes▷ Office Supplies▷ Security Locks▷ Cleaning ProductsKids▷ Baby Strollers▷ Child Car Seats▷ Remote ControlledTravel▷ Luggages & Bags▷ Airlines Seats▷ Hotel Rooms▷ Fun Trips▷ Cruise Ships▷ Mexico Tours