# Python: Input two integers in a single line

## Python Basic: Exercise-134 with Solution

Write a Python program to input two integers on a single line.

**Sample Solution-1:**

**Python Code:**

```
# Print a message to instruct the user to input the values of 'x' and 'y'.
print("Input the value of x & y")
# Use 'map' to apply the 'int' function to the input values and split them into variables 'x' and 'y'.
x, y = map(int, input().split())
# Print the values of 'x' and 'y' after they have been assigned.
print("The value of x & y are: ", x, y)
```

Sample Output:

Input the value of x & y 2 4 The value of x & y are: 2 4

**Sample Solution-2:**

**Python Code:**

```
# Prompt the user to input the values of 'a' and 'b' and split the input by spaces.
a, b = [int(a) for a in input("Input the value of a & b: ").split()]
# Print the values of 'a' and 'b' after they have been assigned.
print("The value of a & b are:", a, b)
```

Sample Output:

Input the value of a & b: 2 4 The value of a & b are: 2 4

**Python Code Editor:**

**Previous:** Write a Python program to calculate the time runs (difference between start and current time)of a program.

**Next:** Write a Python program to print a variable without spaces between values.

**What is the difficulty level of this exercise?**

Test your Programming skills with w3resource's quiz.

**Weekly Trends**- 100 Python Projects for Beginners with solution
- Mastering NumPy: 100 Exercises with solutions
- SQL Tutorial
- SQL Inner Join
- Python Exercises, Practice, Solution
- Python Interview Questions and Answers: Comprehensive Guide
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript HTML Form Validation
- Java Collection Exercises