En Sat, 26 Apr 2008 20:50:57 -0300, <[EMAIL PROTECTED]> escribió:
> ok.. I finally made something that works.. Please let me know what you
> think:
>
def lines(letters):
> fin = open('words.txt')
> count = 0
> rescount = 0 # count the number of results
> results = ""
On Sat, Apr 26, 2008 at 7:50 PM, <[EMAIL PROTECTED]> wrote:
> ok.. I finally made something that works.. Please let me know what you
> think:
>
> >>> def lines(letters):
> fin = open('words.txt')
> count = 0
> rescount = 0 # count the number of results
> results
ok.. I finally made something that works.. Please let me know what you
think:
>>> def lines(letters):
fin = open('words.txt')
count = 0
rescount = 0 # count the number of results
results = "" # there are words that contain the letters
for line in fin:
This is what I'm stuck on. I keep doing things like:
for line in fin:
for ch in letters:
if ch not in line:
I've tried
for ch in letters:
for line in fin:
too..
Should I use a while statement? What's the best way to compare a
group of letters to a line?
> This would be a m
> Is the way I wrote the function inherently wrong? What I wrote
I would not say that. I think a lot of people probably start off like
that with python. You'll find in most cases that manually keeping
counters isn't necessary. If you really want to learn python though,
I would suggest using b
Eric,
Thank you for helping.
Is the way I wrote the function inherently wrong? What I wrote
returns the sequence, however I'm trying to make the output match for
the letters in the string entered, not necessarily the string
sequence. For example if I search words.txt with my function for
'uzi'
> Python Programmer" and have been trying to write a script that checks
> 'words.txt' for parameters (letters) given. The problem that is the i
> can only get results for the exact sequence of parameter 'letters'.
The "re" module comes to mind:
text = open('words.txt','r').read()
letters = 's
Hello all,
I've been trying to teach myself python from "How to Think Like a
Python Programmer" and have been trying to write a script that checks
'words.txt' for parameters (letters) given. The problem that is the i
can only get results for the exact sequnce of parameter 'letters'.
I'll spare po