If you're getting "ValueError: Unterminated string", here's why

  • 10

    If you're getting something like this

    Line 42: ValueError: Unterminated string starting at: line 1 column 1 (char 0)

    when clicking Run Code, LeetCode OJ has a problem. Open up the the Custom Testcase, and you'll see that OJ has converted \n and \t into whitespace, which is mucking things up. Copy-paste the strings in the statement of the problem in, and it'll work.

  • 0

    Looks like it's been fixed, if you open the Custom Testcase, it's formatted properly. However, as pointed out in this post, some of the actual test cases have 4 spaces instead of tabs. Is it an edge case that was missed, or is the problem not stated fully?

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.