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 Types and Branching Numeric

is there use for, instead of int('11'), something like int('hello world')?

to put it in simpler terms is there or would there...or is it even possible to pass a string with words? example like in the question int('hello world') or float('hello world')

i know i might be thinking too much into it but im reviewing the course and dotting my i crossing my t's sort of speak.

please, and thank you

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! If you try and pass in a string that can not be converted to a number such as "hello" you will get back a ValueError. This differs slightly from TypeError. For example, the int function can take either a string or a number. But not all strings can be converted to an integer. The string "42" can be converted to an integer, but the string "my dog" can not. This is when we get a ValueError, the type of the data you're sending in (string) is supported, but the value is such that the task still cannot be completed. However, if you were to send in a list, then you would receive a TypeError as it is neither a string, nor a number.

Hope this helps! :sparkles: