Let's Learn Python - Basics #5 of 8 - Exception Handling

preview_player
Показать описание
This week, I cover the EXCEPTION HANDLING: we use TRY, EXCEPT, PASS, RAISE, FINALLY.

Please leave me a comment or question below! Like and Subscribe to show your support! :D

DOWNLOAD PYTHON:

=========================================

Music by Juto: Link Coming Soon!

=========================================
--- SUPER TUTORIAL LIST!!! ---

PLAYLISTS

=========================================
Рекомендации по теме
Комментарии
Автор

while True:
    print("These videos are AWESOME!")

rlrskr
Автор

As someone who studied Fortran in college... you have no idea how much I'm loving Python right now.

# This right here made me so happy!

myDi={}
myDi["House Pets"] = ["Cat", "Dog", "Useless fish", "Bird"]
myDi["Random Key"] = [10, "George Clooney"]

for i in [range(-2, 5, 1), myDi["House Pets"], myDi.values(), ["bear", "koala"]]:
for j in i:
print j 


Python gives us so much flexibility! It's unbelievable. 

I'm still just glancing at the surface, but I'm already in love with this language.

CookieDynamics
Автор

Your videos are so good man, I've looked at a couple different youtube tutorials now and they all just progress so fast while still being boring AF. With yours I can actually pay attention, follow along, and understand most of what you're saying. Plus that voice is golden.
Would love it if you did like a lecture kind of thing for these lessons that just demonstrate how these code functions are used and helpful in real world practice. I know for myself at least that it would really help solidify my memory of how to use them.
Either way, I really appreciate the videos and I can't wait to continue on through the rest of your playlist. Cheers mate!

RECTmetal
Автор

straight to the fun stuff! subscribed. you earned it :D

pakng
Автор

T-Payne, you have amazing videos! From the audio and music, all the way to your teaching style and animations, the videos are great and I highly appreciate your work. Thank you!!!

salpalo
Автор

You do tutorials way better than me and a lot of other people, thanks!

AstralWolfer
Автор

Thank you so much TPayne for these videos! They are super helpful! You are great at explaining things! Keep up with the good work :)

charlotteduoyizhao
Автор

I was doing your first question of final examples the output i got was
got it! I'm awesome!
Traceback (most recent call last):
File "<stdin>", line 6, in <module>
TypeError: Just kidding!
But as you said that final should be printed first then the actual error that means it should print just kidding first
Please clear my doubt which one is correct
Thank you in advance

niveditakatare
Автор

Hi!
These videos are extremley helpful!
question, when i  do raise and finally,
the error that i make causes another error,
heres all the errors i got (including the one i made)
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
  File "C:\Users\Amparo\AppData\Local\Programs\Python\Python35\lib\idlelib\run.py", line 353, in runcode
    exec(code, self.locals)
  File "<pyshell#25>", line 2, in <module>
TypeError: unsupported operand type(s) for +: 'int' and 'str'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Amparo\AppData\Local\Programs\Python\Python35\lib\idlelib\run.py", line 126, in main
    ret = method(*args, **kwargs)
  File "C:\Users\Amparo\AppData\Local\Programs\Python\Python35\lib\idlelib\run.py", line 365, in runcode
    print_exception()
  File "C:\Users\Amparo\AppData\Local\Programs\Python\Python35\lib\idlelib\run.py", line 216, in print_exception
    print_exc(typ, val, tb)
  File "C:\Users\Amparo\AppData\Local\Programs\Python\Python35\lib\idlelib\run.py", line 211, in print_exc
    traceback.print_list(tbe, file=efile)
  File "C:\Users\Amparo\AppData\Local\Programs\Python\Python35\lib\traceback.py", line 22, in print_list
    for item in
  File "C:\Users\Amparo\AppData\Local\Programs\Python\Python35\lib\traceback.py", line 370, in format
    frame.filename, frame.lineno, frame.name))
AttributeError: 'tuple' object has no attribute 'filename'

>>> RESTART

august
Автор

Hi Trevor Payne
Where r u😢
I luv Ur video
I appreciate Ur work hard ☺️

syazairdina
Автор

i like how hes name sounds like a gangsta
T PAYNE more like T PAIN

Jesus_
Автор

Hey TPayne, what is the purpose of the 'exception:' when you use 'finally:' ? If it doesn't get printed out why bother putting it there? 

maresfillies
Автор

Nicely explained! :)

But I don't understand the 'Finally' section. Why it only shows 'the final word!' as output?

I think, the output should be:
will not see this
the final word!

As the try block gives an error, the exception block is executed and then finally block is executed.

@Trevor Payne Please help me to understand this & correct me if I am wrong.

dipti.borade
Автор

Your videos are awesome man thank you!!!

jakecolleo
Автор

Hello,
thank you very much for you tutorials. Amazing work!

rfrantax
Автор

I struggle with understanding this specific example:

for i in range (10 ):
if (i % 2):

pass

else:

continue

print (i)

when I preform that specific example on IDLE, i'd expect it to print only multiples, since the word "pass" is supposed to tell the computer to skip the numbers with a reminder when dividing by 2, but for some reason it does it the other way, could someone explain this to me?

benzeltser
Автор

I have a sort of fundamental question about how to learn and so I hope someone an answer this for me. I have been watching these repeatedly for about a week now because I am going for a sort of "rote memorization" skill set as opposed to a "I'll get the concepts and use the dictionary later if I need it." In other words, should I try to know this like the back of my hand and go over the same stuff over and over or should I say, "I kinda get that. If I forget what one command does for whatever, I'll come back and look it up later when I need it?

goadsaid
Автор

When I do the example at the end, it always reaches the "finally:", even if an early "except:" condition was met.
If it met an earlier condition, it activates both statements.
Is that supposed to happen?

Nick-jbxi
Автор

At 5:11sec screen shows ZeroDivision but the IDLE has ZeroDivisionError.

guttikondau
Автор

heya  i made this little piece of code and whenever it's supost to add a new minute instead it just stops :/ . can't figure out why this is.
here is the code:
import time
s=0
m=0


while(s < 60):
    time.sleep(1)
    s += 1
    print(m, "minutes", s, "seconds")
if(s >= 60):
    m +=1

Max-bhtg