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 trialnave lahav
388 Pointswhy is this false?
it seems to run fine but doesnt complete the challenge
using System;
namespace Treehouse.CodeChallenges
{
class Program
{
static void Main()
{
try{
Console.Write("Enter the number of times to print \"Yay!\": ");
var times = Console.ReadLine();
int number = Int32.Parse(times);
int i = 0;
while(i != number)
{
if(number<=0){
Console.Write("You must enter a positive number.");
continue;}
i+=1;
Console.WriteLine("Yay");
}
}
catch(FormatException)
{
Console.Write("You must enter a whole number.");
}
}
}
}
1 Answer
Jon Wood
9,884 PointsYou almost got it! I believe your negative number check just needs to be moved before the while
loop. Try moving that and, since you're not in a loop anymore you can remove the continue
statement. Also, try to make it so that if the input is a negative number it doesn't go into the while loop and just prints to the console. Let me know if you need more help!
nave lahav
388 Pointsnave lahav
388 PointsI did exactly what you said and I have the same problem, btw thanks for replying its relly helpful
Jon Wood
9,884 PointsJon Wood
9,884 Pointsnave lahav Can you post your new code? I'll take a look at that to help you a bit further. :)