

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Possible Words using given characters in Python
In this article we are going to see a python program that will give output of possible words from a given set of characters. Here we are taking a list as an input which will contain the set of reference words and another list containing the characters from which the words are made up of.
In the below program, we define two functions. One to take the letters from the second list and make up words. Another function to match the words formed with the words present in the given list of words.
Example
def Possible_Words(character): x = {} for n in character: x[n] = x.get(n, 0) + 1 return x def character_set(w, character): for char in w: value = 1 m = Possible_Words(char) for k in m: if k not in character: value = 0 else: if character.count(k) != m[k]: value = 0 if value == 1: print(char) data = ['fat','tap','day','fun','man','ant','bag','aim'] words = ['m','t','e','d','f','a','p','y','i'] character_set(data, words)
Output
Running the above code gives us the following result −
fat tap day aim
- Related Questions & Answers
- Python program to print Possible Words using given characters
- Print all valid words that are possible using Characters of Array in C++
- Python - Generate all possible permutations of words in a Sentence
- Reverse words in a given String in Python
- Python - Find words greater than given length
- Find k longest words in given list in Python
- Find all possible substrings after deleting k characters in Python
- Python program to Count words in a given string?
- Extract only characters from given string in Python
- Check if a two-character string can be made using given words in Python
- Print all possible words from phone digits in C++
- Python – Strings with all given List characters
- Get similar words suggestion using Enchant in Python
- Python - Largest number possible from list of given numbers
- Convert given time into words in C++
Advertisements