The Artima Developer Community
Sponsored Link

Python Answers Forum
check the first letter in every row

2 replies on 1 page. Most recent reply: May 20, 2006 3:29 AM by Jay Chue

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
mike g

Posts: 1
Nickname: gotohell
Registered: Apr, 2006

check the first letter in every row Posted: Apr 6, 2006 6:25 AM
Reply to this message Reply
Advertisement
Hello.. I'm trying to write a function that will check if the first letter in every row IN a textfile is what I want.

I've come this far, but don't know how to go on..

def selectOne(self):
thefile = open("people.txt", "r")

choice = int(raw_input("Enter ID-number: "))

for line in thefile:
print thefile.read(1)
thefile.close()


if I do this.. It just returns five empty rows.. There is 5 lines in my txt.

someone who can give me some hints?


James Watson

Posts: 2024
Nickname: watson
Registered: Sep, 2005

Re: check the first letter in every row Posted: May 16, 2006 10:14 AM
Reply to this message Reply
print line[1]

Jay Chue

Posts: 1
Nickname: glacjay
Registered: May, 2006

Re: check the first letter in every row Posted: May 20, 2006 3:29 AM
Reply to this message Reply
print line[0]

Flat View: This topic has 2 replies on 1 page
Topic: I broke my IDLE... Previous Topic   Next Topic Topic: Freelance Opportunity

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use