3

In Python, is there a way to make

a, b, c, d, e = 'dog'

so that

a = 'dog'

b = 'dog'

#etc.

or

a, b, c, d, e = list()

so that

type(a through e) 

returns

type 'list'
max
  • 49,282
  • 56
  • 208
  • 355
André Foote
  • 366
  • 3
  • 15

2 Answers2

4

This has already been answered here: Set multiple variables to the same value in Javascript

in python it would be:

a = b = c = d = e = 'dog'

its the same in javascript but with 'var' at the beginning:

var a = b = c = d = e = 'dog'
Community
  • 1
  • 1
Viraj Shah
  • 990
  • 8
  • 8
1

In c# in would be as simple as declaring the variables and then setting them all equal.

string a,b,c,d;

a = b = c = d = "dog";
Jason Roell
  • 6,679
  • 4
  • 21
  • 28