Sam wrote: > I tried to clear the buffer using sys.stdin.flush() but > it seem not work. In general you can't flush the standard input, it is one of those undefined behaviors in C. To read the input until an end-of-file is reached use read() instead of readline(). Istvan.