How do I generate random but unique numbers in python?
问题 I want to generate a random number, and that random number should be unique, meaning it should not be repeated or generated again. I have tried making a list where I append in every iteration and check if it is already present in the list or not. If it is present in the list, the number is not appended. But I don't think it is an effective method. So, please help me with it. import random #an empty list to append randomly generated numbers empty = [] while True: #checking from range 500 to