Hi Tom,
Glad you got it working with Danny's help.
I'll throw in some style points too.
> input = open('/home/tom/Python/Input/SPY3.txt', 'r')
> N=0
> s = 'boo'
> while s:
>s = input.readline()
>if s == '':break
You might find it easier to use a for loop.
you could for example use
fo
Alan,
Thanks for your comments. I see how I can simplify my code, but I've run
into a problem trying to do so. If I replace the "while" loop with a
"for" loop as you suggest, the program won't enter the loop unless "s"
is initialized so that it's in "input". How do I do that?
Also, near the en
> "for" loop as you suggest, the program won't enter the loop unless
> "s" is initialized so that it's in "input". How do I do that?
for s in input:
means that s takes on each value in input.
input is your file. Thus s takes on the value of each line in
the input file. You don't need to initiali
Alan,
Now I understand! Thanks again for the explanation!
Alan G wrote:
>> "for" loop as you suggest, the program won't enter the loop unless
>> "s" is initialized so that it's in "input". How do I do that?
>
>
> for s in input:
>
> means that s takes on each value in input.
> input is your fil