-2

#when I type this I get an error and I cant figure it out. What I want is a random selection from the list.

import random
movies = ["pulp fiction", "peter pan", "toy story"]
watch = random.choice[movies]

TypeError Traceback (most recent call last) in () ----> 1 watch = random.choice[movies]

TypeError: 'method' object is not subscriptable

bhristov
  • 3,137
  • 2
  • 10
  • 26
Brian
  • 1
  • 1
    Can you choose a different title for this question? – Peter O. Jun 22 '20 at 07:45
  • https://stackoverflow.com/questions/4550505/getting-a-random-value-from-a-javascript-array – Darren Street Jun 22 '20 at 08:32
  • Does this answer your question? [Getting a random value from a JavaScript array](https://stackoverflow.com/questions/4550505/getting-a-random-value-from-a-javascript-array) – bjoster Jun 22 '20 at 09:36

1 Answers1

1

You used square bracket instead of parentheses. Change your last line into :-

watch = random.choice(movies) 
ClassHacker
  • 394
  • 3
  • 11