What is the purpose of the second "print" in this Python code?
-
I got this from a Python tutorial, but he doesn't explain why, after print(i, end=' '), there is another print(). The code works fine without the second print(), so why's it there? def main(): func() def func(): for i in range(10): print(i, end=' ') print() if __name__ == "__main__": main()
-
Answer:
print() by itself defaults to end='\n', so it will print out a blank line. I can't say why the tutorial author wanted a blank line to be printed at this point.Typing help(print) will give you more information.
Steve McConville at Quora Visit the source
Other answers
Just to get a blank line between prints of i I think
Dirk Nachbar
Related Q & A:
- What was the purpose of the triple alliance?Best solution by Yahoo! Answers
- What is the purpose of PERT?Best solution by searchsoftwarequality.techtarget.com
- What is UNICEF and what is their purpose?Best solution by Yahoo! Answers
- What is the purpose of UNICEF?Best solution by Yahoo! Answers
- What is the purpose of photosynthesis?Best solution by wiki.answers.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.