[Tutor] dictionary swittching

Sharriff Aina nhytro-python@web.de
Tue, 14 May 2002 11:59:23 +0200


hello!
can someone tell me how to create key dependant actions? I have a dictionary that varies in contents:

## code snippet

selector = ['a', 'b', 'c']

x = {'a': 1245, 'b': 'hello, 'c': 4444}

if "a" in x:
  print 'test1'
elif 'b' in x:
  print 'test2'
elif 'c' in x:
  print 'test3'

this does not work, any ideas?


great thanks


Sharriff
________________________________________________________________
Keine verlorenen Lotto-Quittungen, keine vergessenen Gewinne mehr! 
Beim WEB.DE Lottoservice: http://tippen2.web.de/?x=13