I agree. The reason for this is, that a computer can not just generate a random number. It does not have emotions to pick a number, it must solve it mathematically. There is no equation not actually giving the same each time.
So you have to seed the rand function with the current time. Then in theory tho, rand would return the same if the time is the same each time you run it. Although that shouldn't be the case, since I believe the time function returns the time since 1970 or something.
I already knew that about the "randomness". But random means
an event not able to be predicted by a human. Although I tried this
but when I rerun the program works fine but when I loop on it it doesn't :S
The random number generator has a specific starting value and follows a mathematical formula to generate the next number. If you know the starting value and the formula, you can predict the series that it will generate. That's just the way computerized random number generators are, some are better than others.
What you need to remember is that you have to "seed" the random number generator with a random value to set the starting point. The most reliable way to do this is using srand((unsigned)time(0)); at the beginning of your code. The value of time() is one of the few things in computing that has enough variation in it to simulate true randomness.
Post the section of your code that generates and displays your random numbers. We should be able to tell you what's going on then...
Move the srand() to the very beginning of your program, you only need to do it once for each time the program runs, not for each iteration of your "loop", or every time you use rand().
I suspect that as fast as modern computing equipment runs you are repeatedly re-seeding the random number generator to the same starting value each time. This would have the effect of causing the generator to produce the same 3 numbers repeatedly. The value of time only changes (I believe) once every second (but it may be every millisecond). You can use rand() thousands, if not millions, of times before it needs to be re-seeded.
root = tkinter.Tk()
buttons=[i for i in range(10)]
#If specific button is pressed, output "YES"
for num in buttons: