PPA-5

Question

Accept two words as input and print the two words after adding a space between them.

Hint

String concatenation is a good place to start:

first = 'one'
second = 'two'
print(first + second)

The output is:

onetwo

How do you modify the code so that there is a space between one and two? This is something for you to think about.

Solutions

first = input()
second = input()
space = ' ' # there is one space between the quotes
out = first + space + second
print(out)

The print function adds space as a default separator when multiple arguments are passed to it.

first = input()
second = input()
print(first, second)

Here, we are explicitly specifying the separator to be space.

first = input()
second = input()
print(first, second, sep = ' ') # one space between the quotes