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

Python

LETTER GAME QUESTION

What is print('\n\n') and end='' mean? what do they do? any other samples? I am so confuse:(

def draw(bad_guesses, good_guesses, secret_word):
  clear()

  print('Strikes: {}/7'.format(len(bad_guesses)))
  print('')

  for letter in bad_guesses:
    print(letter, end=" ")
  print('\n\n')

  for letter in secret_word:
      if letter in good_guesses:
        print(letter, end='')
      else:
        print("_", end='')

  print('')

1 Answer

\n stands for a New line. Kenneth was just making a couple new lines so that the game would look better.

If you press return or enter on your keyboard, it should make a new line.

By default, when you print something, it adds an extra newline to the end of the string.

So when I print two things:

print("Hello")
print("World")

The output will be:

Hello
World

However, if we set the end to be a space on the "Hello" print like this:

print("Hello", end=" ")
print("World")

Then the output will look like this:

Hello World

And of course, if we change the end to an underscore the output will look like this:

Hello_World

You see? That's how the "end" argument works.

Good luck! ~alex

thank you alex!!!

You're welcome :)