def random_different_from(top_range, number_to_not_repeat): result = random.randint(0, top_range-1) while result == number_to_not_repeat: result = random.randint(0, top_range-1) return result