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 trialPui Lun Christin C Hebron
5,693 PointsWe've assigned the string "123" to a variable named string. Take string, use a method to convert it to an integer, and s
I am a bit confused about this question. This is what I have
string = "123" integer = 123 string = integer.to_i
float = 123.0 string = float.to_i
Please help?
string = "123"
# YOUR CODE HERE
integer = 123
string = integer.to_i
float = 123.0
string = float.to_f
1 Answer
Steven Parker
231,269 PointsThe instructions tell you to to convert the variable "string" to an integer, and to a float. You won't need to use any literal numbers in your code.
Pui Lun Christin C Hebron
5,693 PointsPui Lun Christin C Hebron
5,693 PointsI tried eliminating the numbers in the code like this, but not working
string = integer.to_i
string = float.to_f
Steven Parker
231,269 PointsSteven Parker
231,269 PointsCheck your syntax again. The thing being assigned goes on the left side of the operator (=), and the thing providing the value goes on the right.