If it works all right here, on Online GBD, can you try to install Python on your own PC and try to run it there?
This test would verify if this is a behaviour specific to Online GBD (preventing users to hog resources for a long time) or it's Python, or maybe something is not OK with the code itself.
I did the same thing: ran a simple code on both Online GBD and on a physical virtual machine. The Online GDB code timed out, while the one running on my machine still keeps running (and waiting for user input).
It looks like my suspicion was correct: it's Online GDB trying to keep the resource usage low.
For the record, this is the code I ran, nothing interesting, nothing demanding:
name = input("What's your name? ")
print("Your name is: " + name)