Program 24
Write a program that asks the user for a word and finds all the smaller words that can be made from the letters of that word. The number of occurrences of a letter in a smaller word can’t exceed the number of occurrences of the letter in the user’s word.
from itertools import permutations
w=input("Enter A Word:")
for i in range(2,len(w)):
for p in permutations(w,i):
print(''.join(p),end=' ')
Ouput:
=== RESTART: D:/old/r19 lab-python/24.py ========
Enter A Word: CSE
CS CE SC SE EC ES
====== RESTART: D:/old/r19 lab-python/24.py ========
Enter A Word:crre
cr cr ce rc rr re rc rr re ec er er crr cre crr cre cer cer rcr rce rrc rre rec rer rcr rce rrc rre rec rer ecr ecr erc err erc err
>>>
No comments:
Post a Comment