Is ValueError the exception you’d expect on EOF? Wouldn’t that be EOFError?
You really need to retain the indentation for Python code. Either indent the entire code by four spaces, of place three back ticks ``` on a line by themselves both before and after the code.