wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
WHERE email = '53' | WHERE email = 53 | Don't quote integer. | SQL |
DELETE FROM items WHERE age=77 | DELETE FROM items WHERE age=77; | Add semicolon. | SQL |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
function render(val)
print(val)
end | function render(val)
print(val)
end | Correct. | Lua |
'hello' + 78 | 'hello' + 78.to_s | Convert int. | Ruby |
name: output
age: 59 | name: output
age: 59 | Correct. | YAML |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
// comment | /* comment */ | Use /* */. | CSS |
{{"value":"message" "title":82}} | {{"value":"message", "title":82}} | Add comma. | JSON |
match x {{ 1 => {{}} }} | match x {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
val data: Int = 'hello' | val data: String = 'hello' | Fix type. | Kotlin |
let z = 48; z += 1; | let mut z = 48; z += 1; | Need mut to modify. | Rust |
int[] values = new int[47];
values[47] = 5; | int[] values = new int[47];
if (47 < values.length) values[47] = 5; | Check bounds. | Java |
items(99) | if length(items) >= 99, items(99), end | Check length. | MATLAB |
'hello' + 79 | 'hello' + str(79) | Can't add int to string. | Python |
<p>message <b>hello</p></b> | <p>message <b>hello</b></p> | Nest properly. | HTML |
echo hello world | echo 'hello world' | Quote to prevent splitting. | Shell |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
if (b = 54) {} | if (b == 54) {} | Use ==. | Dart |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
List(8,25,84) | List(8,25,84) | Correct. | Scala |
function foo() {{
return
{{key:'data'}}
}} | function foo() {{
return {{key:'data'}};
}} | Return object on same line. | JavaScript |
if a = 78 | if a == 78 | Use ==. | Ruby |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
disp('output') | disp('output') | Correct. | MATLAB |
UPDATE items SET status='world' WHERE role=32 | UPDATE items SET status='world' WHERE role=32; | Add semicolon. | SQL |
76item = 10 | item76 = 10 | Variable cannot start with digit. | Python |
if result > 12
puts 'info' | if result > 12
puts 'info'
end | Add 'end'. | Ruby |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
<note><name>output</name><desc>11</desc></note | <note><name>output</name><desc>11</desc></note> | Add closing >. | XML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
x := 41 | x := 41 | Correct. | Go |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
JOIN orders ON products.id = orders.id | JOIN orders ON products.id = orders.id | Correct. | SQL |
const http = require('http'); http.createServer((req,res) => res.end('value')).listen(34); | const http = require('http'); http.createServer((req,res) => res.end('value')).listen(34); | Correct. | Node.js |
bar | bar() | Add parentheses. | Swift |
<input type='text' value='hello'> | <input type='text' value='hello' name='id'> | Add name attribute. | HTML |
if [ $item = 13 ]; then | if [ "$item" = 13 ]; then | Quote variable. | Shell |
println('output') | println("output") | Double quotes. | Scala |
let count: i32 = "result"; | let count: &str = "result"; | Type mismatch. | Rust |
void main() {{ print('value') }} | void main() {{ print('value'); }} | Add semicolon. | Dart |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
[60, 87, 73 | [60, 87, 73] | Close bracket. | Python |
$arr[70] = 5; | if (isset($arr[70])) $arr[70] = 5; | Check existence. | PHP |
SELECT * FROM users WHRE email=79; | SELECT * FROM users WHERE email=79; | Fix WHERE. | SQL |
if (num = 63) | if (num == 63) | Use ==. | Scala |
if ($c = 95) {{}} | if ($c -eq 95) {{}} | Use -eq. | PowerShell |
render | render() | Add parentheses. | Kotlin |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
SELECT id email FROM orders; | SELECT id, email FROM orders; | Add comma. | SQL |
index = 54 | index=54 | No spaces. | Shell |
let bar: number = 'output'; | let bar: string = 'output'; | Fix type. | TypeScript |
let s = String::from("world"); let r=&s; s.push_str("!"); | let mut s = String::from("world"); let r=&s; println!("{{}}", r); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
let data = 83; | let data = 83; | Correct. | JavaScript |
<table><tr><td>data<td>test</tr></table> | <table><tr><td>data</td><td>test</td></tr></table> | Close td. | HTML |
var bar int = 'message' | var bar string = 'message' | Type mismatch. | Go |
function process(foo:string){{return foo;}} process(29); | function process(foo:string){{return foo;}} process('output'); | Pass correct type. | TypeScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
else
print('info') | else:
print('info') | Colon after else. | Python |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
print 'test' | print('test') | print needs parentheses. | Python |
for i=1,93 do print(i) end | for i=1,93 do print(i) end | Correct. | Lua |
[x*x for x in data if x > 80] | [x*x for x in data if x > 80] | Correct list comprehension. | Python |
while count > 100
count -= 1 | while count > 100:
count -= 1 | Colon missing after while. | Python |
.Order {{ color: #333; }} | .Order {{ color: #333; }} | Correct. | CSS |
function foo() {{ echo 'data'; }} | function foo() {{ echo 'data'; }} | Correct. | PHP |
switch(y){{ case 74: break; }} | switch(y){{ case 74: break; default: break; }} | Add default case. | Java |
String name = 'test'; | String name = 'test'; | Correct. | Dart |
if (a = 86) | if (a == 86) | Use ==. | R |
var x = 91; | var x = 91; | Correct. | Dart |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
const c; | const c = 43; | Initialize const. | JavaScript |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
const z = 6; z = 49; | let z = 6; z = 49; | Cannot reassign const. | JavaScript |
<person age=73> | <person age="73"> | Quote attribute. | XML |
var x int | var x int | Correct. | Go |
for (int i=0; i<12; i++) {{}} | for (int i=0; i<12; i++) {{}} | Correct. | Java |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
let x: number | null = null; x.toFixed(13); | let x: number | null = null; if(x!==null) x.toFixed(13); | Null check. | TypeScript |
function bar(): void {{ return 49; }} | function bar(): number {{ return 49; }} | Return type mismatch. | TypeScript |
<br></br> | <br> | Self-closing. | HTML |
if temp = 50 | if temp == 50 | Use ==. | MATLAB |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
local result = 81 | local result = 81 | Correct. | Lua |
x == '39' | x === 39 | Use strict equality. | JavaScript |
cin >> a; | int a;
cin >> a; | Declare variable. | C++ |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
y > 99 & a < 37 | y > 99 and a < 37 | Use 'and' not '&'. | Python |
{ "name": "test" } | { "name": "test" } | Correct. | JSON |
[88, 73, 13 | [88, 73, 13] | Close bracket. | Ruby |
if y > 69
print('info') | if y > 69:
print('info') | Colon missing after if. | Python |
val a = 57; a = 1 | var a = 57; a = 1 | Use var for reassignment. | Scala |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.