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!

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 (2015) Number Game App Number Game Refinement

livia salgado
livia salgado
4,407 Points

at minute 1.24 Kenneth says So we want to safely make an int, because right now we're not doing that. What do you mean?

on the video at 1 minute 24 seconds Kenneth says safely make an int, i really don't know what that means, thanks!

1 Answer

Alex Koumparos
Alex Koumparos
Python Development Techdegree Student 36,886 Points

Hi Livia,

Whenever you do a type conversion from string to int there is a risk that the string value is something that can't be converted to a int (e.g., 'hello'). Without error handling code this would cause the program to crash. Because of the risk of crashing, this kind of type conversion is described as 'unsafe'.

By wrapping this unsafe operation in a try block which means we can handle the cases when an invalid value gets passed to the type conversion, we take away that crash risk and so make the 'unsafe' behaviour 'safe'.

Hope that clears it up.