ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> python-tutor
python-tutor
Re: [Tutor] can anyone help me in solving this problem this is urgent
by Shashwat Anand other posts by this author
Nov 7 2009 8:22AM messages near this date
Re: [Tutor] can anyone help me in solving this problem this is urgent | [Tutor] Classes that do operator overloading
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, surjit khakh <surjitkhakh@[...].com>  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. Articles in the English
>  language are the
>  words �a�, �an�, and �the�.
> 
>  _______________________________________________
>  Tutor maillist  -  Tutor@[...].org
>  To unsubscribe or change subscription options:
>  http://mail.python.org/mailman/listinfo/tutor
> 
> 
Thread:
Surjit Khakh
Emile van Sebille
Prasad Mehendale
Alan Gauld
Shashwat Anand

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved