Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
expecting and raising exceptions
I am having a problem with these thing. My raising exception code I could not figure out. These two are very complex. For me.
First of all, it's always a good idea to include your code in your question.
Catching and raising exceptions are used when you know something might crash your program. If you have a function that can take invalid input (like the input function), you surround that code with the try function. Then, you use the catch function to prevent the exceptions you think might happen. If there were no exceptions, you use the else keyword to continue reading your code.
The raise function is used when you can catch an exception manually. Instead of using the try, you use other methods like if statements. You then use the keyword "raise" to catch that error in your error handling code. That code might reset some variables and ask the user for input again, so instead of re-writing all of that code you write it in your catch and use it as your exception protocol for the rest of the script.
def suggest(product_idea): return product_idea + "inator" raise ValueError
yes email is great
def suggest(product_idea): return product_idea + "inator" raise ValueError I had this down before would never send without work. Sorry. I'm getting two errors.