Write a python program that will take two inputs from the user: 1st Input: a string where each number is separated by a comma. You should make a list of the numbers present in the 1st input and print it to the user. 2nd input: a number ( integer). Your task is to identify two numbers from the list whose ABSOLUTE difference is equal to the 2nd input. If such a pair of numbers don’t exist in the list, then print ‘Not Possible’. Otherwise, print those two numbers. Note: There can be more than one pair of numbers resulting in the same difference. It’s sufficient to print any one of those. You need to use the built-in function abs() to get the difference of two numbers.
Write a python program that will take two inputs from the user:
1st Input: a string where each number is separated by a comma. You should make a list of the numbers present in the 1st input and print it to the user.
2nd input: a number ( integer).
Your task is to identify two numbers from the list whose ABSOLUTE
difference is equal to the 2nd input. If such a pair of numbers don’t exist in the list, then print ‘Not Possible’. Otherwise, print those two numbers.
Note: There can be more than one pair of numbers resulting in the same difference. It’s sufficient to print any one of those. You need to use the
built-in function abs() to get the difference of two numbers.
Sample Input 1:
1, 17, 22, 38, 5, 11
5
Sample Output 1:
['1', ' 17', ' 22', ' 38', ' 5', ' 11']
17, 22
Step by step
Solved in 3 steps with 1 images