"Válas Péter" <suli...@postafiok.hu> wrote

I have a dictionary with the keys 'a' and 'b'. It is not in a class.
May I use the value of 'a' when defining the value of 'b'?
If so, what is the syntax?

single = {'a': 1,
               'b': 2
              }
double = { 'a': single['a'] *2,
                  'b' : single['b'] * 2
                }

single['c'] = 3
double['c'] = single['c'] * 2

Does that help?
Is that what you mean?

--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to