Debug and fix code instantly
Paste broken code and get fixes with clear explanations. Torki identifies bugs, suggests optimizations, and rewrites with improvements — supporting Python, JavaScript, SQL, and more.
Try in TorkiPaste your code
Drop in the function, query, or file that isn’t working. Include any error messages you’re seeing. Torki works with Python, JavaScript, TypeScript, SQL, PHP, Go, Rust, and most popular languages.
This Python function should calculate compound interest but it’s giving wrong results: def compound_interest(principal, rate, years) amount = principal * (1 + rate) ** years interest = amount - principl return interest
Get fixes with explanations
Torki identifies every bug, explains why it’s wrong, and provides the corrected code. It doesn’t just fix — it teaches you what went wrong so you can avoid similar mistakes.
Ask for optimizations
Beyond fixing bugs, ask Torki to optimize for performance, add error handling, write tests, or refactor for readability. It understands the broader context of your code.
def compound_interest(principal, rate, years)
amount = principal * (1 + rate) ** years
interest = amount - principl
return interest1. Missing colon on the function definition line.
2. Typo:
principl → should be principal.3. Rate should be divided by 100 if passed as a percentage.
Fixed code:
def compound_interest(principal, rate, years):
decimal_rate = rate / 100
amount = principal * (1 + decimal_rate) ** years
interest = amount - principal
return round(interest, 2)Test it:>>> compound_interest(1000, 5, 10)
628.89Ready to try for yourself?
Paste your broken code. Torki finds the bugs, explains them, and gives you the fix.
Try in Torki