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 trialNeil Shweky
5,022 PointsLimiting integer to two numbers
Hi, I have a label in which I am printing an integer. I want to make it that no matter how many numbers you press only two numbers are printed, the last two inputted. Also the value of this number should be equal to what is printed. (Sort of like how you would input numbers into a timer...)
How do I do this?
Thanks!
1 Answer
Ricardo Hill-Henry
38,442 PointsI would convert the number to a string then substring it. only grabbing the last two numbers. After that, you can either leave it as a string, or convert it back to an integer..
Neil Shweky
5,022 PointsNeil Shweky
5,022 PointsWow! Great idea! I'll try it