Python Forum
trying to input a variable using random.choice
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
trying to input a variable using random.choice
#4
Using 'list' as a name is not great idea and should be avoided (unless one likes nasty surprises down the road):

>>> spam = list()
>>> spam
[]
>>> list('abc')
['a', 'b', 'c']
>>> list = []
>>> spam = list()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'list' object is not callable
>>> list('abc')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'list' object is not callable
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Messages In This Thread
RE: trying to input a variable using random.choice - by perfringo - Aug-13-2020, 05:34 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  combobox_callback(choice choice part of openfile name (kind of dependency) janeik 9 3,392 Sep-10-2023, 10:27 PM
Last Post: janeik
  input variable choice MCL169 7 2,324 Feb-19-2023, 09:00 PM
Last Post: MCL169
  Whys is asterisk and random variable necessary in these functions? rrowhe4d 5 2,548 Aug-05-2022, 07:53 AM
Last Post: Gribouillis
  How to include input as part of variable name Mark17 4 3,739 Oct-01-2021, 06:45 PM
Last Post: Mark17
  random.choice HELP samuelbachorik 4 3,243 Aug-18-2021, 03:24 PM
Last Post: naughtyCat
  Unable to use random.choice(list) in async method spacedog 4 4,831 Apr-29-2021, 04:08 PM
Last Post: spacedog
  Generate Random operator, take user input and validate the user mapypy 4 7,714 Feb-03-2021, 08:41 PM
Last Post: nilamo
  Calling Input for Random Generation ScaledCodingWarrior 1 2,522 Feb-02-2021, 07:27 PM
Last Post: bowlofred
  Help with a random.randint choice in Python booponion 5 4,061 Oct-23-2020, 05:13 PM
Last Post: deanhystad
  ???: if "{choice}" in self._command BaiYouLing4 3 2,884 Aug-23-2020, 05:40 AM
Last Post: BaiYouLing4

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020