by BehindJava

# Write a program to Accept Three Digits and Print all Possible Combinations from the Digits in Python

Home » python » Write a program to Accept Three Digits and Print all Possible Combinations from the Digits in Python

In this tutorial we are going to learn about accepting Three Digits and Print all Possible Combinations from the Digits in Python.

# Python Program to Accept Three Digits and Print all Possible Combinations from the Digits

``````a=int(input("Enter first number:"))
b=int(input("Enter second number:"))
c=int(input("Enter third number:"))
d=[]
d.append(a)
d.append(b)
d.append(c)
for i in range(0,3):
for j in range(0,3):
for k in range(0,3):
if(i!=j&j!=k&k!=i):
print(d[i],d[j],d[k])``````

### Explanation

1. User must enter the first, second and third number.
2. All the elements are appending into a list for the ease of comparison.
3. The for loops range from 0-2 which are basically the indexes of the three elements in the list.
4. If none of the indexes are equal to each other, the element associated with the particular element in the list is printed.