You can use a while statement until you get a number out of your excluded numbersexcludedNumbers = [1,2,3,4] randomNumber = random.randomint(1,100) while randomNumber in excludedNumbers: randomNumber = random.randomint(1,100) After the while you have a number outside the excluded numbers
-- https://mail.python.org/mailman/listinfo/python-list