Following are the different ways of selecting a random element from a list:
random.randrange()
random.random()
random.choice()
random.randint()
1.
random.randrange() :using this method we can return a random element from the given list.This method generates random value in the specified range.so for lists we need to specify the range as " random.randrange(len(listname)) ".And we will pass the value returned by the above method into our list to genereate the random elementfrom the list....
Published on November 01, 2020 21:57