About 38,600 results
Open links in new tab
  1. python - How to use Random Randint for List ? - Stack Overflow

    Oct 14, 2014 · And randint(a, b) is just "an alias for randrange(a, b+1)". So, you know how to use choice from Martijn Pieter's answer, you know what choice does, you should be able to figure …

  2. Using random.randint help in python - Stack Overflow

    Feb 28, 2012 · list_name = [randint(0,100) for x in range(x)] This will generate randint(0,100) x times in a list, which will allow you to access all the values later. To fix up your code as close …

  3. python - Generate random integers between 0 and 9 - Stack …

    Oct 22, 2010 · 2 If we look at their source implementations, random.randrange() (and random.randint() because it is the former's syntactic sugar) use a while-loop to generate a …

  4. Python and random.randint() - Stack Overflow

    A quick search brought me to the Python manual page on random.randint(): Return a random integer N such that a <= N <= b . Your creating a variable rand which is equal to a random …

  5. Generate random number in range excluding some numbers

    Mar 24, 2017 · from random import randint exclude = [2, 5, 7] while (number := randint(0, 9)) in exclude: pass The while loop will continue to assign randint(0, 9) to number end exit only if it is …

  6. How to use the output of randint in an if statement (Python)

    Mar 17, 2018 · The 1st time you used random.randint(1, 1000) it was statically added only to be used in the print statement. So what I did here is save the random.randint(1,1000) (as you can …

  7. randomly choose from list using random.randint in python

    How to use random.randint() to select random names given in a list in python. I want to print 5 names from that list. Actually i know how to use random.randint() for numbers. but i don't know …

  8. python - How to generate random integers with multiple ranges?

    Oct 3, 2021 · for i in (randint(1,5),randint(9,15),randint(21,27)): print i This foor loop will generate 3 random numbers one from the first range supplied, another for second range and last one for …

  9. How to use randint for strings in Python 3? - Stack Overflow

    How to use randint for strings in Python 3? [duplicate] Ask Question Asked 7 years, 11 months ago.

  10. How do i get 10 random values in python? - Stack Overflow

    Sep 8, 2014 · Use randint function 10 times to get 10 random numbers. In your code, you had used randint two times to get two random numbers for x and y. Yes, you can use randint as …

Refresh