- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Python Program to Accept Three Digits and Print all Possible Combinations from the Digits
When it is required to print all possible combination of digits when the input is taken from the user, nested loop is used.
Below is a demonstration of the same −
Example
first_num = int(input("Enter the first number...")) second_num = int(input("Enter the second number...")) third_num = int(input("Enter the third number...")) my_list = [] print("The first number is ") print(first_num) print("The second number is ") print(second_num) print("The third number is ") print(third_num) my_list.append(first_num) my_list.append(second_num) my_list.append(third_num) 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(my_list[i],my_list[j],my_list[k])
Output
Enter the first number...3 Enter the second number...5 Enter the third number...8 The first number is 3 The second number is 5 The third number is 8 3 5 8 3 8 5 5 3 8 5 8 3 8 3 5 8 5 3
Explanation
The three numbers re taken as input from the user.
An empty list is created.
The three numbers are displayed on the console.
These numbers are appended to the empty list.
Three nested loops are used, and the numbers are iterated over.
When they are not equal, their combinations are displayed as output on the console.
- Related Articles
- Golang Program to Read Three Digits and Print all Possible Combinations from the Digits
- Print all possible words from phone digits in C++
- How to generate a list of all possible 4 digits combinations in Excel?
- Python Program to print all distinct uncommon digits present in two given numbers
- Python – How to Extract all the digits from a String
- Program to replace all digits with characters using Python
- C++ program to convert all digits from the given range into words
- Java program to accept an integer from user and print it
- Write all possible 3- digit numbers (without repeating the digits) , by using the digits.(i)6,7,5 (ii) 9,0,2
- Program to find minimum digits sum of deleted digits in Python
- Python program to get all pairwise combinations from a list
- All possible numbers of N digits and base B without leading zeros?
- List all the three digit numbers can be made from the digits 0,5,9 without repetition.
- Program to find the sum of all digits of given number in Python
- Finding all possible combinations from an array in JavaScript

Advertisements