-3

I have and array containing 10 words and i need to take out 9 words that are not the same; and put them into another array. The array: array = ["night", "smoke", "ghost", "tooth", "about", "camel", "brown", "funny", "chair", "price"] 8 bit swog swig

Community
  • 1
  • 1
  • This question has been asked a hell lot of times. Nevertheless, I'll post my answer. – Eli Korvigo Mar 11 '15 at 12:58
  • possible duplicate of [Python choose a non-repeating random element from a list](http://stackoverflow.com/questions/24087435/python-choose-a-non-repeating-random-element-from-a-list) – Eli Korvigo Mar 12 '15 at 15:01

1 Answers1

1
import random

array = ["night", "smoke", "ghost", "tooth", "about", "camel", "brown", "funny", "chair", "price"]
new_array = random.sample(array, 9)

P.S.

Lists are not arrays. Python has built-in arrays, but they are rarely used.

Eli Korvigo
  • 10,265
  • 6
  • 47
  • 73