print the random list's item index number in python

0 votes
I have a list and I would like to print the random list's item index number. How do I do that in python?
May 28, 2019 in Python by Alia
66 views

1 answer to this question.

0 votes

Hey @Alia, you can use a python function called random.randrange()

from random import randrange
random_index = randrange(len(list))
print(list[random_index])
answered May 28, 2019 by Patrick

Related Questions In Python

+4 votes
1 answer

Print the odd and even factors of a number in Python

x = int(input("Enter any number \n")) print("The factors ...READ MORE

answered Nov 19, 2018 in Python by Nabarupa
3,055 views
+1 vote
7 answers

Count the frequency of an item in a python list

To count the number of appearances: from collections ...READ MORE

answered Oct 18, 2018 in Python by tinitales
8,214 views
0 votes
1 answer

How can I find out the index of an element from row and column in Python?

You probably want to use np.ravel_multi_index: [code] import numpy ...READ MORE

answered Apr 16, 2018 in Python by charlie_brown
• 7,780 points
273 views
0 votes
2 answers

Finding the index of a character in python string

You can use word.find('o') as well to ...READ MORE

answered Jun 1, 2018 in Python by george
• 200 points
276 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 1,182 views
0 votes
0 answers
+4 votes
6 answers
+6 votes
6 answers

What exactly is the function of random.seed() in python?

The seed method is used to initialize the ...READ MORE

answered Oct 29, 2018 in Python by Rahul
82,353 views
–1 vote
1 answer