bug-fixer / fix_generator.py
venky2k1
Final working bug fixer with fixed detection and suggestion
d57024f
raw
history blame
537 Bytes
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