Skip to content
Back to formatted view

Raw Message

Message-ID: <41A20905.3000405@lancaster.ac.uk>
Date: 2004-11-22T15:43:01Z
From: Barry Rowlingson
Subject: How to insert one element into a vector?
In-Reply-To: <200411220929.06611.deepayan@stat.wisc.edu>

Deepayan Sarkar wrote:

> Pretty much what 'append' does.

  A shame then, that help.search("insert") doesn't find 'append'! I cant 
think why anyone looking for a way of _inserting_ a value in the middle 
of a vector would think of looking at "append"!

  Python has separate insert and append methods for vectors.

  >>> x=[1,2,3,4,6]
  >>> x.insert(4,5)
  >>> x
  [1, 2, 3, 4, 5, 6]
  >>> x.append(99)
  >>> x
  [1, 2, 3, 4, 5, 6, 99]


Barry