HELP: Tabs Instead of spaces

Hi All!

I’m making a hangman game for a uni project. I’m storing the characters of the word & the characters guessed in list. When I print the list I’m printing it to a string. when the string prints the the letter is wrong I add a space however instead of the string just having 1 space it seems to be added 4 or more.

can somebody help me with this URGENTLY

public void SetCharUI() {
        WrongL = "";
        Debug.Log(GuessedWrong.Count);
        for (int i = 0; i < GuessedWrong.Count; i++) {
           
            WrongL += GuessedWrong[i] + " ";
           
        }

        GuessedWord = "";
        for (int j = 0; j < Characters.Count; j++) {
            string c = Characters[j].ToString();
            for (int n = 0; n < GuessedCorrect.Count; n++) {
                string a = GuessedCorrect[n].ToString();
                if (c == a) {
                    GuessedWord += c;
                } else {
                    GuessedWord += " ";
                }
            }
        }

        DisplayedWord.text = GuessedWord;
        WrongLetters.text = WrongL;

    }

Nested for loop could be the issue I feels.

What do you think the best way to fix it is?

Don’t know for sure but maybe echo the space printout " " in the first for loop rather than the nested one.

Sorry I’ve said print. I meant that I’m placing the string into a text object, would that make a difference?

So for each letter in the original string
you compare it against each and every letter of the guess string.
And if it doesnt match the you print a space.

But you dont know why you have more than one space?

If you have 4 letters in the words, how many times do you check the individual letters of your guess against the first letter of the hidden word?

How many times could it match?
How many times could it not match?

1 Like