I'm extremely new to Python (as in this is the first script I've written), and I'm just messing around trying to make something that will work.
I've written the following:
# Roll the Dice
from random import randint
x = randint.uniform(1, 6)
y = randint.uniform(1, 6)
print str(x + y)
This should simply return any integer between 2 and 12, but I'm getting the following error message when I try to run it:
Traceback (most recent call last):
File "C:/FilePath/Python Testing.py", line 5, in <module>
x = randint.uniform(1, 6)
AttributeError: 'function' object has no attribute 'uniform'
I feel like this is a super easy script and shouldn't be failing, but since I'm so new to this I don't even know where to begin troubleshooting. I found this SO question that is similar, but the resolution does not fit my problem (or so I think).
I'm using Python 2.7.12 via PyCharm 2016.1.4
Any help is appreciated!
random.uniform, notrandint.uniform. You'll have to change your import toimport random, orfrom random import uniformand then you can use the unqualified name.uniformto simulate dice rolls, since it returns floats.