Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python Basics Functions and Looping Raising Exceptions

This lesson and last lesson are a bit hard to understand..

Are their any smaller programs that do the same thing...I've gone word blind, and very confused.. Feel like i've missed an entire course between these few lessons

5 Answers

Steven Parker
Steven Parker
231,236 Points

Perhaps you just need a break to recover from mental exhaustion. There's actually a course here on How to Learn, it's full of suggestions on ways to overcome common issues folks face when trying to learn lots of new things quickly.

There's also an episode of The Treehouse Show that discusses an experience students have called "hitting the wall", and how to manage it. The instructor even quotes me at one point.   :smile:

Steven Parker
Steven Parker
231,236 Points

Having "gone word blind" sounds pretty serious, so exhaustion seemed like a likely cause.

But in any case, you can expect that some concepts will be more challenging to master than others, and the tips in the learning videos might be helpful.

Alyssa Wren
Alyssa Wren
1,758 Points

I completely agree and it has nothing to do with mental exhaustion- I found every lesson up to this point extremely easy to understand and was getting 100% on the quizzes. This lesson was hard to follow and I felt many concepts were introduced and glossed over far too quickly

Alyssa Wren & Luis Cardenas Hello to you both, I just want to say although its difficult at times learning at Treehouse I find that Treehouse does a good job to guide me in the right direction but occasionally the above does happen and at time like these I refer to books - I know I shouldn't have to but I do. In this case I've brought a book called Python by Mike McGrath and once I've learnt the missing links as it were I will go back to Treehouse and continue to learn from them. Hope that helps, and don't give up!!! All the best, Jason.

same here :/

Alyssa Wren & Luis Cardenas Hello to you both, I just want to say although its difficult at times learning at Treehouse I find that Treehouse does a good job to guide me in the right direction but occasionally the above does happen and at time like these I refer to books - I know I shouldn't have to but I do. In this case I've brought a book called Python by Mike McGrath and once I've learnt the missing links as it were I will go back to Treehouse and continue to learn from them. Hope that helps, and don't give up!!! All the best, Jason.

Michael Jacoby
seal-mask
.a{fill-rule:evenodd;}techdegree
Michael Jacoby
Full Stack JavaScript Techdegree Student 3,793 Points

Hi Steven and others,

I equally found this portion of learning difficult and I don't think it's burnout or hitting the wall.

If you rewatch this video, you'll see that Craig shows us that when 0 is typed in (for number_of_users), a ZeroDivisionError is generated. He doesn't really explain the purpose of raising an exception and it really doesn't even seem to work properly. He certainly makes it seem more difficult to raise the ValueError.

After watching his video and practicing, I don't even see how raising an exception is beneficial.

Rather than put a ZeroDivisionError in the try block, he explains that nobody should be typing in 0 for number_of_users, so...

1) He has a ValueError in his try block 2) Raises another ValueError in the function (with an if statement), and when it's still not outputting properly... 3) He moves amount_due from else to within the try block Finally, when it's still not outputting the error message he raised (in the function), 4) He adds "as err" to his ValueError and adds a 2nd print statement: print("({})".format(err))

Yeah, I think that's all pretty confusing.

So I put all this to the test and my simple solution is to add a ZeroDivisionError to the try block. I get it, nobody should be typing in 0 for number_of_people, but it seems like Craig went through a lot of work and I'm not sure if he was not fixing it along the way on purpose - for training purposes - or if he was tripped up. But it is confusing.

Here is my code. Note that I used amount_of_people (not number_of_people), so don't be confused there.

import math
def split_check(total, amount_of_people):
#    if amount_of_people <= 1:
#        raise ZeroDivisionError("zip dude")
#    if amount_of_people <= 1:
#        raise ValueError("Dude")
    return math.ceil(total/amount_of_people)
try:
    total_due = float(input("Total? "))
    amount_of_people = int(input("amount_of_people? ")) # 0 people generates a ZeroDivisionError, but 0 is not possible, so they typed wrong.
    amount_due = split_check(total_due, amount_of_people)
except ValueError:  # This is where Craig put as err and added a 2nd print statement (as mentioned above)
    print("Value Error")   # in conjunction with the raised exception (I commented out), that's how Craig got his text to output)
except NameError:
    print("Name Error")
except ZeroDivisionError:  # I used this. Seems simpler.  
    print("Zero Div Error")
else:
    print("Each person owes ${}".format(amount_due))
Adriana Leon
Adriana Leon
241 Points

I have to agree with others, I feel like this lesson should have been split into 5 different ones explaining one by one. I'm not burned out our exhausted, it just felt like the video was running across 10 new things way too fast without really explaining much in a beginner language... I guess I'll just skip it and hope it will come to me sometime in the future.