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 My Solution

Print function.

Can I fit all these 3 sentences by calling a print function only one time in the code so each one would start from the next line like when you call print function three times for each sentence, I tried to isolate each sentence so it started from the next line, but in console it still gives me 3 connected sentences.

3 Answers

Steven Parker
Steven Parker
231,248 Points

The "print" function automatically adds a newline at the end for you. You can add them yourself before the end by using the special symbol sequence "\n". For example:

print("This is line one.\nThis is line two.")

And the output will be:

This is line one.
This is line two.

Yes thats the way i implemented my practice solution

verb = input("Tell us one verb about what area does practice help you: ") noun = input("tell us one noun about what would be affected if you did not practice: ") adjective =input("Okay tell us one adjective about what your code is doing because of practice: " )

Here

print(" I enjoy practice! I find it helps me to {} better.\n Without practice, my {} would not even work.\n My code is getting more {} every single day !".format(verb, noun,adjective))

But, lets say, if Im going to use my input name in the end of the first line like ("Hello,", first_name) or start my second line with input name (first_name,"...") - how do I apply this method,cause it seems to like when the whole 2 lines are usual words and simply marked with quotation marks at the start and finish,but when the input or output assignation squeezes in within all syntax rules ,it starts to highlight the backslash red saying that it is an error.

Steven Parker
Steven Parker
231,248 Points

Add the newline inside the strings:

print("Hello, " + first_name + ".\nHow are you?")