if needs_quotes:
    return '"' + s + '"'
else:
    return s
assert quotify('') == '""'
assert quotify('type') == '"type"'
assert quotify('"type" /?') == '""type" /?"'
assert quotify('"type" "/?"') == '""type" "/?""'
assert quotify('type "a a" b') == '"type "a a" b"'
assert quotify('type "" b') == '"type "" b"'
assert quotify('"type"') == '"type"'
assert quotify('""type" /?"') == '""type" /?"'
How to properly add quotes to a string using python?