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.

Python Python Basics (2015) Letter Game App Review: Python Basics

Kishore Kumar
Kishore Kumar
5,451 Points

python Basics

try: count = int(input("Give me a number: ")) except ValueError: count = 0

----------------------------: return count * 15

Please fill the correct answer

I think this question needs to be more specific or something because I can program in python and I couldn't get what you wanted from this question. And the review video had nothing to do with the answer at all.

2 Answers

Joakim Skansen Flatmoen
PLUS
Joakim Skansen Flatmoen
Courses Plus Student 24,223 Points

try: count = int(input("Give me a number: ")) except ValueError: count = 0 else: return count * 15

Michel Moreau L
Michel Moreau L
21,751 Points

Why does that make any sense? I mean...it is syntactically correct, but would it be useful to use that kind of combination for any problem to solve?

Joakim Skansen Flatmoen
Joakim Skansen Flatmoen
Courses Plus Student 24,223 Points

Exception handling generally can be very useful.

When an exception occures in Python, it Causes the current process to stop and passes it to the calling process until it is handled. If not handled, our program will crash. For example, if function A calls function B wooden in turn calls function C and an exception occures in function C. If it is not handled in C, the exception passes to B and then A. If two never handled, an error message is spit out and our program come to a sudden, unexpected halt.

For a list of built-in exceptions please see the following url: https://docs.python.org/3.3/library/exceptions.html

I am unsure if this answered your question?

Vladan Grubesic
Vladan Grubesic
3,855 Points

The answer here is "else".

try: 
    count = int(input("Give me a number: ")) 
except ValueError: 
    count = 0
else: 
    return count * 15