0

Ok, so I know for example you can just give the words value individually like one=1 two=2 and so on, but if there was a lot of words, is there not an easier way to do this. I seem to remember you can do it with lists, but if you can I cant remember how.

user2970954
  • 89
  • 1
  • 3
  • 7
  • What do you mean by _"words"_? Variables? Dictionary keys? – Alexander L. Belikoff Nov 19 '13 at 21:33
  • Can you give an example of input and output? – jramirez Nov 19 '13 at 21:34
  • Enumerations? http://stackoverflow.com/questions/36932/how-can-i-represent-an-enum-in-python. A dictionary with Key/Value pairs sounds like what you are looking for... – WebDevNewbie Nov 19 '13 at 21:36
  • Are you looking for this? http://stackoverflow.com/questions/4010840/generating-variable-names-on-fly-in-python – tmj Nov 19 '13 at 21:40
  • Is python expected to correctly assign 23121 to the word "twenty_three_thousand_one_hundred_twenty_one"? Or should it be assigned to "two_three_one_two_one"? Similarly, would 10 be mapped to "ten" or "one_zero"? – MxLDevs Nov 19 '13 at 21:44

1 Answers1

0

You can do:

>>> one, two, three = [1,2,3]

In Python 3 you can also do:

>>> a, b, *others = [1,2,3,4,5]
>>> a
1
>>> b
2
>>> others
[3, 4, 5]
Simeon Visser
  • 118,920
  • 18
  • 185
  • 180