lists + string

holger krekel pyth at devel.trillke.net
Fri May 10 11:51:44 EDT 2002


ian wrote:
> hi started to learn python this week
> and my lecturer threw us in the deep end
> and asked us to write a mail server.. oh well

check the 'smtpd' mail server module :-)

> anyway in the program i read in some input from the user
> 
> input = str(raw_input .........
> 
> how do i compare it to an element in a list??
> 
> ive tried
> 
> for x in list
>     if input == x:print 'found item'

if x in stringlist:
	print "yes,",x," is in",stringlist
	# additionally get the index...
	index = stringlist.index(x)

have fun,

    holger





More information about the Python-list mailing list