New
#1
Python Script for "Change A Letter Game [2] "...
Well, I just finished a script in Python to help select a new word for the Change a Letter Game. The inputs are 1) letter to skip and then the three letters to look for. So far it looks/works great and I plan on working on the code to add a function. Is the cheating.. yes but the goal was to write a useful and fun script in Python ver 2.7.9.
PHP Code:
#-------------------------------------------------------------------------------
#
#-------------------------------------------------------------------------------
found_letters = int(0)
new_words = list()
#Get letter to skip and the 3 letters to serch for,,
skip_letter = raw_input("Enter letter to skip:")
letter_one = raw_input("Enter first letter to search for:")
letter_two = raw_input("Enter second letter to search for:")
letter_three = raw_input("Enter third letter to search for:")
fh = open("words.txt",'r')
for line in fh:
word = line.rstrip().lower()
for x in range(1,4):
if (skip_letter == word[x]):
found_letters += 1
if (found_letters == 0):
for x in range(1,4):
if (letter_one == word[x]):
found_letters += 1
if (found_letters == 1):
for x in range(1,4):
if (letter_two == word[x]):
found_letters += 1
if (found_letters == 2):
for x in range(1,4):
if (letter_three == word[x]):
found_letters += 1
if (found_letters == 3):
new_words.append(word)
found_letters = 0
#Print out results...
entries = len(new_words)
for x in range(0,entries):
print "New word:",x + 1," ", new_words[x]
Last edited by BunnyJ; 21 Feb 2015 at 18:13. Reason: Add content..