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
Bruce Röttgers
18,211 PointsWhat's the difference between using print(...) and print(..., end="yourtext")
Wouldn't it result in the same outcome:
print(str1,endstr)
and:
print(str1,end=endstr)
e.g. What is the purpose of the end argument?
1 Answer
Steven Parker
243,318 PointsThe "print" function can take a number of arguments, and by default will print them with a space between each. But "end" is a special argument that indicates what to do after printing the other arguments. By default the end is a new line.
So for these examples:
str1 = "fizz"
endstr = "buzz"
print(str1,endstr) # fizz buzz
print(str1,end=endstr) # fizzbuzz (and no newline)
For more details, see the documentation page on "print".
Bruce Röttgers
18,211 PointsBruce Röttgers
18,211 PointsThanks!