searching strings using variables

tgiles tgiles at
Tue Jun 15 09:44:54 CEST 2004

Hi, all. Another bewildered newbie struggling with Python goodness. This 
time it's searching strings. The goal is to search a string for a value. 
The string is a variable I assigned the name 'myvar'. however, it 
doesn't seem to be seeing it... Here's a snippet.

import re

# list of items to search...
mylist = [ 5 , 6 , 16 , 17 , 18 , 19 , 20 , 21 ]
# my variable I want to search with...
myvar = '16'

... just returns none. Tried it also with...


to see if I could spook it out but I get a ValueError (not in list) so 
it looks like it won't see it either. I did vague permutations trying to 
make it work but no go. I'm thinking it may be one of those "forest for 
the trees" things, i've been looking at it too hard. Any ideas?

many thanks in advance!


More information about the Python-list mailing list