RSS Forums RSS
Please support our Python advertiser: Programming Forums
Views: 1355 | Replies: 1
Join Date: Mar 2007
Posts: 1
Reputation: emzy is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
emzy emzy is offline Offline
Newbie Poster

Searching a text file

  #1  
Mar 28th, 2007
Hi All,

I'm having huge problems with a program that i am attempting to write. What i have is a program that prints Acronyms and sentences to a text file already, now i am trying to create a new program that reads that text file and if the user inputs the same acronym, it will print out the sentence associated with that acronym. This is what i have so far;

import string

def main():

acronymName = raw_input("Enter a sentence that may include more than one acronym ")
fileHandle = open ( 'acronym.txt', 'r' )

for line in fileHandle.readlines():
for acronym in line.split():
if acronym.enswith('nce'):
print acronym


fileHandle.close()

main()


Obviously Im not even sure if i am on the right track. Any help would be appreciated. I can't even seem to find a similar program to compare to.

Thanks Heaps..
AddThis Social Bookmark Button
Reply With Quote  

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 10:06 am.
Newsletter Archive - Sitemap - Privacy Statement - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC