Advertisement
nprasanna

avoid forbidden letters using python

Jun 4th, 2015
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.33 KB | None | 0 0
  1. 'print words not having any of the forbidden letters'
  2. def isNotForbid(word,forbidLetters):
  3.     for letter in word:
  4.         if letter in forbidLetters:                    
  5.             return False
  6.     return True
  7.  
  8. fin=open("words.txt")
  9. forbidLetters = ("a","e","i","o","u")
  10.  
  11. for line in fin:   
  12.     word = line.strip()
  13.     if isNotForbid(word,forbidLetters):
  14.         print word
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement