
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
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 Articles
- Python program to print Possible Words using given characters
- Print all valid words that are possible using Characters of Array in C++\n
- Python - Generate all possible permutations of words in a Sentence
- Find all possible substrings after deleting k characters in Python
- Reverse words in a given String in Python
- Check if a two-character string can be made using given words in Python
- Find k longest words in given list in Python
- Extract only characters from given string in Python
- Python - Find words greater than given length
- Python program to Count words in a given string?
- Python – Strings with all given List characters
- Get similar words suggestion using Enchant in Python
- Python Program – Strings with all given List characters
- Program to find maximum possible value of an expression using given set of numbers in Python
- Swap Corner Words and Reverse Middle Characters

Advertisements