473,322 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

{SOLVED} Program to print 't' and 'T' in a text file

I got such good help here before (thank you)....thought I'd try it again.

I'm supposed to have a text file to read....I named it my_file.txt

I need to write a Python program to read the file and print every word that begins with a 't' or 'T'.

This is what I have so far:

uselessFile = open('my_file.txt', 'r')
>>> uselessList = uselessfile.readlines()
>>> uselessList


Am I on the right track or just really lost?
Nov 12 '06 #1
2 1076
ghostdog74
511 Expert 256MB
one way

Expand|Select|Wrap|Line Numbers
  1. data = open("thefile").read().split()
  2. for items in data:
  3.   if items.startswith("T") or items.startswith("t"):
  4.     print items,
  5.  
Nov 12 '06 #2
I think I'm making this much harder than it is.....what I've been working on for hours you told me in a couple of minutes....THANK YOU SO MUCH!!!!
Nov 12 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Sandman | last post by:
I am splitting a text block into paragraphs, to be able to add images and stuff like that to a specific paragraph in a content management system. Well, right now I'm splittin on two or more...
4
by: Thomas Guettler | last post by:
Hi! This script will convert files to PDF with OpenOffice. Other formats (html, doc ...) should be possible, too. Have a nice day, thomas # OpenOffice1.1 comes with its own python...
6
by: Jocknerd | last post by:
I'm a Python newbie and I'm having trouble with Regular Expressions when reading in a text file. Here is a sample layout of the input file: 09/04/2004 Virginia 44 Temple ...
3
by: R Evans | last post by:
Hello, In a Perl script, I run a program, Program.pl, by using: @output = `cat $file_name | Program.pl`; However I want to run this program when the contents of the file named $file_name...
2
by: vm | last post by:
please help! I can't find anything wrong (except the result ofc ;-) This: picfile = 'logo.gif'
5
by: Mandrah | last post by:
I have a single text file with several lines of information with three items separated by commas. An example of a few lines: name1, email1, password1 name2, email2, password2 name3, email3,...
10
by: wo_shi_big_stomach | last post by:
Newbie to python writing a script to recurse a directory tree and delete the first line of a file if it contains a given string. I get the same error on a Mac running OS X 10.4.8 and FreeBSD 6.1. ...
1
by: jasper123 | last post by:
Hello, I am developing a cgi-perl script that takes some value from a html form as input and stores them in a data file. I have a program called "irr" in my server, it is executed just by typing irr...
5
by: josh001 | last post by:
This Error message pops up every time I run my program using Python Shell and won't open at all when I don't use Shell. Traceback (most recent call last): File "C:\Documents and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.