Spaces:
Runtime error
Runtime error
def generate_fix(code): | |
lines = code.split("\n") | |
fixed_lines = [] | |
for line in lines: | |
line = line.strip() | |
if line.startswith("print ") and not line.startswith("print("): | |
content = line[6:].strip() | |
fixed_lines.append(f"print({content})") | |
else: | |
fixed_lines.append(line) | |
return "\n".join(fixed_lines) | |
# Optional test | |
if __name__ == "__main__": | |
buggy = "a = input()\nprint a" | |
print(generate_fix(buggy)) | |
#genrate the fixed version of code using an ML Model |