Re: learning with python question (HtTLaPP)

2008-04-27 Thread Gabriel Genellina
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 = ""

Re: learning with python question (HtTLaPP)

2008-04-26 Thread Eric Wertman
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

Re: learning with python question (HtTLaPP)

2008-04-26 Thread umpsumps
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:

Re: learning with python question (HtTLaPP)

2008-04-26 Thread umpsumps
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

Re: learning with python question (HtTLaPP)

2008-04-26 Thread Eric Wertman
> 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

Re: learning with python question (HtTLaPP)

2008-04-26 Thread umpsumps
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'

Re: learning with python question (HtTLaPP)

2008-04-26 Thread Eric Wertman
> 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

learning with python question (HtTLaPP)

2008-04-26 Thread umpsumps
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