Getting Random Number From A Prime List In Python
guys i am totally new to programming in python so i need your help please ... i want to generate a prime number from a prime list i have created ... here is my code list = [] for i
Solution 1:
Use import random
instead of from random import random
Solution 2:
In addition to @zero323's answer, if you don't need more than choice
function, you can do this instead:
from random import choice
And use it straight away:
a = choice(list)
Also your program might not do what you wanted. Currently, if you find 5
in your list, you will add a new 5
to the list.
Tips: Never use list
as a variable name! It will override the built-in function with the same name, list
.
Post a Comment for "Getting Random Number From A Prime List In Python"