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 trialVishal Josi
689 PointsProgram works in the Workspace, but not in the Challenge.
I copied and pasted the code into the Workspace and the program runs perfect, but it does not run in the Challenge. In the Challenge, it says that there is a null exception. Is there a problem with the compiler.
using System;
namespace Treehouse.CodeChallenges
{
class Program
{
static void Main()
{
int count=0;
string input = "0";
int repeat=int.Parse(input);
bool InputValidate = false;
while(InputValidate==false)
{
Console.Write("Enter the number of times to print \"Yay!\": ");
input = Console.ReadLine();
try
{
repeat=int.Parse(input);
InputValidate=true;
}
catch(FormatException)
{
Console.WriteLine("You must enter a whole number.");
InputValidate=false;
continue;
}
}
while(count<repeat)
{
Console.WriteLine("Yay!");
count+=1;
}
}
}
}
1 Answer
Steven Parker
231,210 Points Be careful about testing a challenge in an external REPL or IDE.
If you have misunderstood the challenge, it's also very likely that you will misinterpret the results.
In this case, you have added an extra loop that prevents the program from ending if bad values are entered..
A program that follows the challenge instructions will only ask for input one time, and either print "Yay!"s or an error message. But either way it should end.