I want to print either a b or c randomly
someone told me it was like this
import random
array = ['a','b','c','d','e','f']
random = random.choice(array)
print (random)
however I get this error when I do that
SOLVED: Thanks to bsdpunk and fallen, we were able to figure out, that by changing the name of the program. It worked.
someone told me it was like this
import random
array = ['a','b','c','d','e','f']
random = random.choice(array)
print (random)
however I get this error when I do that
Quote:Traceback (most recent call last):
File "random.py", line 2, in <module>
random = random.choice(array)
NameError: name 'random' is not defined
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python2.6/dist-packages/apport_python_hook.py", line 38, in apport_excepthook
from apport.packaging_impl import impl as packaging
File "/usr/lib/python2.6/dist-packages/apport/__init__.py", line 1, in <module>
from apport.report import Report
File "/usr/lib/python2.6/dist-packages/apport/report.py", line 14, in <module>
import subprocess, tempfile, os.path, urllib, re, pwd, grp, os, sys
File "/usr/lib/python2.6/tempfile.py", line 34, in <module>
from random import Random as _Random
File "/home/nevets04/random.py", line 2, in <module>
random = random.choice(array)
NameError: name 'random' is not defined
Original exception was:
Traceback (most recent call last):
File "random.py", line 2, in <module>
random = random.choice(array)
NameError: name 'random' is not defined
SOLVED: Thanks to bsdpunk and fallen, we were able to figure out, that by changing the name of the program. It worked.