title: Declaring Unknown Type Variable in Python?
body: <p>I have a situation in Python(cough, homework) where I need to multiply EACH ELEMENT in a given list of objects a specified number of times and return the output of the elements.  The problem is that the sample inputs given are of different types.  For example, one case may input a list of strings whose elements I need to multiply while the others may be ints.  So my return type needs to vary.  I would like to do this without having to test what every type of object is.  Is there a way to do this?  I know in C# i could just use "var" but I don't know if such a thing exists in Python?</p>
  
  <p>I realize that variables don't have to be declared, but in this case I can't see any way around it.  Here's the function I made:</p>
  
  <pre><code>def multiplyItemsByFour(argsList):
  
  output = ????
  
  for arg in argsList:
          output += arg * 4
  
  return output
  </code></pre>
  
  <p>See how I need to add to the output variable.  If I just try to take away the output assignment on the first line, I get an error that the variable was not defined.  But if I assign it a 0 or a "" for an empty string, an exception could be thrown since you can't add 3 to a string or "a" to an integer, etc...  </p>
  
  <p>Here are some sample inputs and outputs:</p>
  
  <pre><code>Input:  ('a','b')  Output:  'aaaabbbb'
  Input:  (2,3,4)    Output:  36
  </code></pre>
  
  <p>Thanks!</p>