On Sunday 08 November 2009 07:43 am, tutor-requ...@python.org wrote:
>
> In general we don't provide answers to homework questions on this list.
> But we will try to point you in the right direction. But it helps if you
> show us what you've tried so far and tell us what went wrong. Include any
"surjit khakh" wrote
Write a python program to read a text file named “text.txt” and show the
number of times each article is found in the file.
In general we don't provide answers to homework questions on this list.
But we will try to point you in the right direction. But it helps if you
sh
On 11/6/2009 4:24 PM surjit khakh said...
Write a python program to read a text file named “text.txt” and show the
number
of times each article is found in the file. Articles in the English
language are the
words “a”, “an”, and “the”.
Sounds like you're taking a python class. Great! It's p
naive and unoptimized method:
>>> file = open("text.txt", 'r')
>>> s = file.read()
>>> s
'an elephant jump across the room\nhe met a guy\nthe guy was an moron\n'
>>> s = " "+s.replace('\n', ' ')+" "
>>> s.count(' a ')
1
>>> s.count(' an ')
2
>>> s.count(' the ')
2
On Sat, Nov 7, 2009 at 5:54 AM,
Write a python program to read a text file named “text.txt” and show the
number
of times each article is found in the file. Articles in the English language
are the
words “a”, “an”, and “the”.
___
Tutor maillist - Tutor@python.org
To unsubscribe or chan