[Tutor] dictionary swittching
Jörg Wölke
lumbricus@gmx.net
Tue, 14 May 2002 12:27:54 +0200 (MEST)
> hello!
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']
You don't use this.
> x = {'a': 1245, 'b': 'hello, 'c': 4444}
>
> if "a" in x:
if "a" in x.keys():
print "Does that do what you want?"
> print 'test1'
> elif 'b' in x:
> print 'test2'
> elif 'c' in x:
> print 'test3'
>
> this does not work, any ideas?
>
>
> great thanks
>
>
> Sharriff
HTH, HAND and Greetings,
J"o!
--
None
--
GMX - Die Kommunikationsplattform im Internet.
http://www.gmx.net