GoConqr has a new look! Let us know what you think.

Module 13 of 20 · Text

The print() function - using multiple arguments

David Khieu

The print() function - using multiple arguments

So far we have teste the print()  function behavior with no arguments, and with one argument. It's also worth trying to feed the print() function with more than one argument. 

Look at the editor window. This is what we're going to test now. 

There is one print() function invocation, but it contains three arguments. All of them are strings. 

The arguments are separated by commas. We've surrounded them with spaces to make them more visible, but it's not really necessary, and we won't be doing it anymore.

In this case, the commas separating the arguments play a completely different role than the comma inside the string. The former is a part of Python's syntax, the latter is intended to be shown in the console. 

If you look at the code again, you'll see that there are no spaces inside the strings. 

Run the code and see what happens. 

The console should now be showing the following text. 

The itsy bitsy spider climbed up the waterspout.

The spaces, removed from the strings; have appeared again. Can you explain why? 

Two conclusions emerge from this example: 

  • a print() function invoked with more than one argument outputs them all on one line;
  • the print() function puts a space between the outputted arguments on its own initiative.

Instructions

You must submit an attempt for this quiz to progress. You can submit it after the last question.

Go to the chosen module

Feedback

What is it about?

What do you think of the new look?

How do you like it?