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 trial

C# C# Basics (Retired) Perfect Final

nave lahav
nave lahav
388 Points

why is that wrong?

it says it didn't get what it was expecting while I copy paste the same thing

Program.cs
using System;

namespace Treehouse.CodeChallenges
{
    class Program
    {
        static void Main()
        {

            try { Console.Write(" Enter the number of times to print \"Yay!\": ");
                     var i = 0;
                     var num = int.Parse(Console.ReadLine());
                     while(true)
                     {
                         if(i>= num) 
                         { break; }
                         Console.WriteLine("Yay!");
                         i+= 1;
                     }  
                }
                 catch(FormatException)
                 { 
                     Console.Write("You must enter a whole number."); 
                 }

        }
    }
}
Jon Wood
Jon Wood
9,884 Points

I ran your code and so far it looks good to me. What error is it saying?

1 Answer

Steven Parker
Steven Parker
231,248 Points

It looks like you altered the original Write statement.

The instructions say, "Leave this as it is.", but it looks like you added a space at the beginning before the word Enter.

Put that line back the way it was and you should pass task 2.

But what did you mean by "copy paste the same thing" .. same as what? Aren't you writing the code for this challenge for the first time?

nave lahav
nave lahav
388 Points

the text that should appear

Steven Parker
Steven Parker
231,248 Points

You shouldn't have to copy/paste that. It was given in the challenge code to start with.

Anyway, just remove that extra space at the beginning of the string and you'll pass.