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 (2015) Python Data Types Naming Things

Syntax error with division problem

I'm using the terminal to practice along, and just defining favorite_number = 42 makes python think it's a string or integer, so I get a syntax error when I try to do the division problem. Defining the variable as 42.0 lets it know it's a floating point, and then it will complete the division problem. Is that right, or is there a better way to do it?

2 Answers

Steven Parker
Steven Parker
231,248 Points

I would not expect Python to think 42 was a string unless you put quotes around it. Maybe the question would make more sense if you show all of the code.

got it, thanks! Looks like I did have quotes around it by accident