wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
UPDATE products SET email='data' WHERE email=29 | UPDATE products SET email='data' WHERE email=29; | Add semicolon. | SQL |
math.sqrt(80) | import math
math.sqrt(80) | Import module first. | Python |
const a; | const a = 61; | Initialize const. | JavaScript |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
println('value') | println("value") | Double quotes. | Scala |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
let num: number = 'world'; | let num: string = 'world'; | Fix type. | TypeScript |
<hr></hr> | <hr> | Self-closing. | HTML |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if ($bar = 46) {{}} | if ($bar -eq 46) {{}} | Use -eq. | PowerShell |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
<ul><li>hello<li>world</ul> | <ul><li>hello</li><li>world</li></ul> | Close li. | HTML |
if (c = 28) | if (c == 28) | Use ==. | Scala |
let b = 66; b += 1; | let mut b = 66; b += 1; | Need mut to modify. | Rust |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
while foo > 69
foo -= 1 | while foo > 69:
foo -= 1 | Colon missing after while. | Python |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
items(76) | if length(items) >= 76, items(76), end | Check length. | MATLAB |
[37, 67, 75 | [37, 67, 75] | Close bracket. | Python |
yield num | yield num | Correct yield. | Python |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
jwt.sign({{id:39}}, 'secret'); | jwt.sign({{id:39}}, 'secret', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(27); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(27, () => console.log('listening')); | Add callback. | Node.js |
String foo = 'result'; | String foo = "result"; | Double quotes. | Java |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
assert val > 97 | assert val > 97 | Correct. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
def bar(c):
return c + 1 | def bar(c):
return c + 1 | Correct. | Python |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
function baz() {{ echo 'hello'; }} | function baz() {{ echo 'hello'; }} | Correct. | PHP |
if a > 87
print('world') | if a > 87:
print('world') | Colon missing after if. | Python |
def baz():
print('output') | def baz():
print('output') | Indent function body. | Python |
switch(index){{ case 98: break; }} | switch(index){{ case 98: break; default: break; }} | Add default case. | Java |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
object User {{ def main(args: Array[String]) = println("info") }} | object User {{ def main(args: Array[String]): Unit = println("info") }} | Add return type Unit. | Scala |
val z = 'value' | val z = "value" | Double quotes. | Kotlin |
{{'value':'hello'}} | {{"value":"hello"}} | Use double quotes. | JSON |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
int[] values = new int[75];
values[75] = 5; | int[] values = new int[75];
if (75 < values.length) values[75] = 5; | Check bounds. | Java |
const data = 14; data = 99; | let data = 14; data = 99; | Cannot reassign const. | JavaScript |
'info' + 99 | 'info' + str(99) | Can't add int to string. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
WHERE id = '60' | WHERE id = 60 | Don't quote integer. | SQL |
let mut item=65; let r1=&mut item; let ref2=&mut item; | let mut item=65; {{ let r1=&mut item; }} let ref2=&mut item; | Only one mutable borrow. | Rust |
function foo() {{
return
{{key:'message'}}
}} | function foo() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
<img src='data.jpg'> | <img src='data.jpg' alt='desc'> | Add alt text. | HTML |
val z = 20; z = 41 | var z = 20; z = 41 | Use var for reassignment. | Scala |
// comment | /* comment */ | Use /* */. | CSS |
<table><tr><td>world<td>data</tr></table> | <table><tr><td>world</td><td>data</td></tr></table> | Close td. | HTML |
let c = 54; | let c = 54; | Correct. | JavaScript |
<input type='text' value='result'> | <input type='text' value='result' name='status'> | Add name attribute. | HTML |
{ "name": "test" } | { "name": "test" } | Correct. | JSON |
my @arr = (74,40,26); | my @arr = (74,40,26); | Correct. | Perl |
disp('output') | disp('output') | Correct. | MATLAB |
list.forEach(function(foo) {{ console.log(foo); }}) | list.forEach((foo) => {{ console.log(foo); }}) | Arrow functions are cleaner. | JavaScript |
'message' + 66 | 'message' + 66.to_s | Convert int. | Ruby |
<p>message <b>data</p></b> | <p>message <b>data</b></p> | Nest properly. | HTML |
<br></br> | <br> | Self-closing. | HTML |
if (bar = 2) | if (bar == 2) | Use ==. | C++ |
let x: Int = 'data' | let x: String = 'data' | Fix type. | Swift |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
fn bar() -> i32 {{ 5 }} | fn bar() -> i32 {{ 5 }} | Correct. | Rust |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
if (x = 10) | if (x == 10) | Use ==. | R |
22b = 10 | b22 = 10 | Variable cannot start with digit. | Python |
if (index) console.log('yes') else console.log('no') | if (index) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
["value", 23] | ["value", 23] | Correct. | JSON |
'21' + 97 | 21 + 97 | Avoid string coercion. | JavaScript |
for i=1,81 do print(i) end | for i=1,81 do print(i) end | Correct. | Lua |
$data[62] = 5; | if (isset($data[62])) $data[62] = 5; | Check existence. | PHP |
foo | foo() | Add parentheses. | Swift |
$index = 92; if ($index = 92) {{}} | $index = 92; if ($index == 92) {{}} | Use ==. | PHP |
handle | handle() | Add parentheses. | Kotlin |
DELETE FROM items WHERE name=23 | DELETE FROM items WHERE name=23; | Add semicolon. | SQL |
[26, 53, 46 | [26, 53, 46] | Close bracket. | Ruby |
class User {{ int item; }}; | class User {{ public: int item; }}; | Make public. | C++ |
local data = 17 | local data = 17 | Correct. | Lua |
const http = require('http'); http.createServer((req,res) => res.end('output')).listen(45); | const http = require('http'); http.createServer((req,res) => res.end('output')).listen(45); | Correct. | Node.js |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
let s1 = String::from("test"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("test"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
x := 50 | x := 50 | Correct. | Go |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
if (y = 78) {{}} | if (y === 78) {{}} | Use === for equality. | JavaScript |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
<note><age>value</age><name>77</name></note | <note><age>value</age><name>77</name></note> | Add closing >. | XML |
function foo(item:string){{return item;}} foo(63); | function foo(item:string){{return item;}} foo('value'); | Pass correct type. | TypeScript |
if val = 59 | if val == 59 | Use ==. | Go |
if bar = 59 then
print('output')
end | if bar == 59 then
print('output')
end | Use ==. | Lua |
.Item {{ color: red; }} | .Item {{ color: red; }} | Correct. | CSS |
{{'title':45, 'age' 21}} | {{'title':45, 'age':21}} | Colon missing. | Python |
var x = 78; | var x = 78; | Correct. | Dart |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.