Please help me with the task: Checking if a list contains an item

Hello, I’m working on this task:

Simon is preparing for a raid on the C gang. He wants to choose the best team for this. Unfortunately, Simon can’t just assign the team members: this right in the C# gang belongs to the Council. Council chooses several people to form a team, and Simon has a veto rule: he either agrees to the selected group of people or not. Simon would agree only for the team where he is one of the members.
Write a program that reads from the console the names of people, each from the new line, until the input is “done”. Put each string into the list. If the list contains “Simon”, your program should output “Team accepted” otherwise “Team rejected”.

Team accepted

Here is my code:

using System.Collections.Generic;

namespace Lists
   public class PrepareForTheRaid
       static void Main(string[] args)
           List<string> names = new List<string>();
               string name = Console.ReadLine();
               while (name != "done")


           bool listContainsSimon = names.Contains("Simon");

           if (listContainsSimon)
               Console.WriteLine("Team accepted");

           if (!listContainsSimon)
               Console.WriteLine("Team rejected");



Hi! I got stuck on this task, tried different options, the last version of my code is given above. I’m interested in two things:

  1. Of course, first of all, I need help in finding my mistake in the code.

  2. I’m very curious why exactly my laptop behaves strangely when I run this particular code. It never happened before. As soon as I run it in Visual Code and enter the first name, everything freezes, the computer does not respond to either the mouse or the touchpad, or pressing the buttons and I have to turn it off. In CodeEasy’s output I saw some kind of error related to memory. Now it’s just empty. I am supercurious about what exactly makes the code so memory consuming. :face_with_raised_eyebrow:
    Thanks in advance!

  1. this loop will never end: you’re not changing anything inside of it, so it check if
    "Sintia" != "done" - add to the list.
    “Sintia” != “done” - add to the list,
    etc. until it reaches StackOverFlowException and computer is not possible to do anything else.
    This is why it’s really important to ensure, you’re getting an input / update to the variable inside a while loop

Indeed! Stupid me. Thanks a lot :hugs: Fixed