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 trialmjmj
18,664 PointsStuck. Please help.
I have added continue; to loop around, but error message says, "No enclosing loop out of which to break to or continue".
using System;
namespace Treehouse.CodeChallenges
{
class Program
{
static void Main()
{
Console.Write("Enter the number of times to print \"Yay!\": ");
var entry = int.Parse(Console.ReadLine());
if(entry<=0) {
Console.WriteLine( entry + "You must enter a whole number.");
continue;
}
for(var i = 0; i<entry; i++) {
Console.WriteLine("Yay!");
}
}
}
}
2 Answers
emmuster
1,533 PointsWhat for? You're not looping anything, you're simply checking whether the input of the user is less than or greater than 0. If you remove the "continue;" it should pass the challenge just fine
mjmj
18,664 PointsThank you.
Rohit Gopalan
81,945 PointsYou could also place the following lines into a while loop:
Console.Write("Enter the number of times to print \"Yay!\": "); var entry = int.Parse(Console.ReadLine());
if(entry<=0) {
Console.WriteLine( entry + "You must enter a whole number.");
continue;
}
mjmj
18,664 Pointsmjmj
18,664 PointsThank you Rohit.