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.
The final code gives an invalid literal error message when using a spelled out number. How do I prevent that message?
I am spelling out a number i.e. "Four" instead of "4" and I am getting an error message that says invalid literal.
Steven Parker217,627 Points
int(tickets_requested)" function converts a string made of digits (like "4") into a number (4). But it does not recognize words and that causes a "valueError" to be raised. Your "except" catches this and returns the message you see.
You can easily change the message (or eliminate it), but if you want to convert a word into a number you will need to use a different function to process the input. There's no built-in for this in Python itself, but some user-created modules can be found online. One example is called word2number.