[Tutor] finding strings in other strings

Brett brett42@konaboy.com
Sat, 05 Aug 2000 20:35:30 -1000

	I was making a little program to rename mp3 files, but didnt want it to 
effect other files in the same directory.  I tried using something like 
this to have the program only effect mp3 files:

files  = os.listdir(os.curdir)
for x in files:
	if 'mp3' in x:

After having the program screw up a couple of times I checked out the 
documentation and found out that the first term (in my attempt 'mp3') must 
have a length of 1 if the second term is a string.  I fixed it in this case 
by using <if x[-3:] == 'mp3'>, but i realized this wouldnt work if i wanted 
to locate something like this in the middle of some strings, like if some 
members of a list had a two or three character long string in them and I 
wanted to do stuff only to them.  So anyway, is there a way to determine if 
a string is part of a longer string?  Hope you can understand what i'm 
talking about, had a little trouble figuring out what I wanted to say.

"One World, one Web, one Program" - Microsoft promotional ad
"Ein Volk, ein Reich, ein Fuhrer" - Adolf Hitler