How To Print Space Between Two Numbers In Python

In this tutorial, we’ll learn how to print space between two numbers in Python. This technique can come in handy when designing a program that manipulates large sets of numbers, and you may want to create a more readable or organized output for users.

Step 1: Accepting Input from User

First, let’s take two numbers as input from the user. Use the input() function to accept input from the user and then convert it to an integer using int() function.

Step 2: Creating a Function to Print Space Between Two Numbers

Now, let’s create a function called print_space_between_numbers() that takes two input parameters, num1 and num2, and prints a space between them.

Step 3: Calling the Function with User Input

Finally, we’ll call the print_space_between_numbers() function and pass the two numbers provided by the user as arguments.

This will print the two numbers with a space in between.

Full Code

Example Output

Enter the first number: 5
Enter the second number: 10
5 10

Conclusion

In this tutorial, we learned how to print space between two numbers in Python by taking input from the user, creating a function to print space between the two numbers, and calling the function to print the output. This technique can be useful when working with large sets of numbers, where you want to improve the readability and organization of the output.