Reputation: 11
I am trying to create a random number in Python. For some reason the code shown below does not work.
import random
print random.random()
I receive the following error:
invalid syntax
If anyone has any pointers, I will greatly appreciate it.
P.S. The above code works on some computers (2 out of 30 in a room).
Upvotes: 1
Views: 139
Reputation: 1245
If python 3 is being used, then print is a function and must be called like
print (random.random())
This would also explain why the code works on two computers. They might be running a different version of python.
Upvotes: 3