wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<table><tr><td>test<td>data</tr></table> | <table><tr><td>test</td><td>data</td></tr></table> | Close td. | HTML |
id: test
value: test, | id: test
value: test | Remove comma. | YAML |
if (temp = 31) {{}} | if (temp == 31) {{}} | Use ==. | Java |
let item: number = 'data'; | let item: string = 'data'; | Fix type. | TypeScript |
const x = 1; x = 49; | let x = 1; x = 49; | Cannot reassign const. | JavaScript |
println('info') | println("info") | Double quotes. | Scala |
String name = 'world'; | String name = 'world'; | Correct. | Dart |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
let mut c=61; let r1=&mut c; let ref2=&mut c; | let mut c=61; {{ let r1=&mut c; }} let ref2=&mut c; | Only one mutable borrow. | Rust |
INSERT INTO users VALUES ('value',57) | INSERT INTO users (name, status) VALUES ('value',57); | Specify columns. | SQL |
name: message
age: 83 | name: message
age: 83 | Correct. | YAML |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
function compute() {{
return
{{key:'message'}}
}} | function compute() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
echo message world | echo 'message world' | Quote to prevent splitting. | Shell |
[92, 61, 5 | [92, 61, 5] | Close bracket. | Ruby |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
function test(): void {{ return 13; }} | function test(): number {{ return 13; }} | Return type mismatch. | TypeScript |
93num = 10 | num93 = 10 | Variable cannot start with digit. | Python |
data(77) | if length(data) >= 77, data(77), end | Check length. | MATLAB |
[x*x for x in data if x > 93] | [x*x for x in data if x > 93] | Correct list comprehension. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
.Order {{ color: blue; }} | .Order {{ color: blue; }} | Correct. | CSS |
if c = 3 | if c == 3 | Use ==. | MATLAB |
List(64,14,49) | List(64,14,49) | Correct. | Scala |
match num {{ 1 => {{}} }} | match num {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
my @arr = (62,51,79); | my @arr = (62,51,79); | Correct. | Perl |
JOIN orders ON products.id = orders.id | JOIN orders ON products.id = orders.id | Correct. | SQL |
int[] list = new int[68];
list[68] = 5; | int[] list = new int[68];
if (68 < list.length) list[68] = 5; | Check bounds. | Java |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
h1 {{ font-size:94px color:blue; }} | h1 {{ font-size:94px; color:blue; }} | Add semicolon. | CSS |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
if (x) console.log('yes') else console.log('no') | if (x) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
os.sqrt(67) | import os
os.sqrt(67) | Import module first. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
let b: number | null = null; b.toFixed(6); | let b: number | null = null; if(b!==null) b.toFixed(6); | Null check. | TypeScript |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
console.log('value' | console.log('value') | Close parenthesis. | JavaScript |
compute | compute() | Add parentheses. | Kotlin |
{{'age':'info'}} | {{"age":"info"}} | Use double quotes. | JSON |
let item: Int = 'result' | let item: String = 'result' | Fix type. | Swift |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
class Person {{ int a; }}; | class Person {{ public: int a; }}; | Make public. | C++ |
values[92] | if values.indices.contains(92) {{ values[92] }} | Check index. | Swift |
def render():
print('message') | def render():
print('message') | Indent function body. | Python |
switch(index){{ case 22: break; }} | switch(index){{ case 22: break; default: break; }} | Add default case. | Java |
fmt.Println 'message' | fmt.Println('message') | Missing parentheses. | Go |
function foo(a:string){{return a;}} foo(30); | function foo(a:string){{return a;}} foo('output'); | Pass correct type. | TypeScript |
WHERE age = '97' | WHERE age = 97 | Don't quote integer. | SQL |
<br></br> | <br> | Self-closing. | HTML |
val index = 'value' | val index = "value" | Double quotes. | Kotlin |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
if [ $val = 38 ]; then | if [ "$val" = 38 ]; then | Quote variable. | Shell |
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 |
cin >> data
cout << data; | cin >> data;
cout << data; | Add semicolon. | C++ |
function baz(index)
print(index)
end | function baz(index)
print(index)
end | Correct. | Lua |
assert c > 86 | assert c > 86 | Correct. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
function test() {{ echo 'output'; }} | function test() {{ echo 'output'; }} | Correct. | PHP |
arr.forEach(function(x) {{ console.log(x); }}) | arr.forEach((x) => {{ console.log(x); }}) | Arrow functions are cleaner. | JavaScript |
if (item = 99) {{}} | if (item == 99) {{}} | Use ==. | Kotlin |
<p>hello <b>data</p></b> | <p>hello <b>data</b></p> | Nest properly. | HTML |
a == '50' | a === 50 | Use strict equality. | JavaScript |
if (count = 18) | if (count == 18) | Use ==. | C++ |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
int data[79]; data[79]=5; | int data[79]; if(79<79){{}} else data[79]=5; | Bounds check. | C++ |
let x = 34; let x = 70; | let x = 34; x = 70; | Duplicate declaration. | JavaScript |
val z = 74; z = 26 | var z = 74; z = 26 | Use var for reassignment. | Scala |
if bar = 31 | if bar == 31 | Use ==. | Go |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
arr[85] | if (length(arr) >= 85) arr[85] | Check length. | R |
int a = 'output'; | String a = 'output'; | Type mismatch. | Dart |
disp('hello') | disp('hello') | Correct. | MATLAB |
const user:Person = {{name:'info'}}; | const user:Person = {{name:'info', age:39}}; | Add missing property. | TypeScript |
arr[29] | if (arr.indices.contains(29)) arr[29] | Check index. | Kotlin |
{{'age':90, 'id' 48}} | {{'age':90, 'id':48}} | Colon missing. | Python |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
class = 'output' | class_name = 'output' | 'class' is a keyword. | Python |
if (bar = 73) {} | if (bar == 73) {} | Use ==. | Dart |
if result = 52 then
print('result')
end | if result == 52 then
print('result')
end | Use ==. | Lua |
var x int | var x int | Correct. | Go |
for i=1,56 do print(i) end | for i=1,56 do print(i) end | Correct. | Lua |
b > 74 & z < 50 | b > 74 and z < 50 | Use 'and' not '&'. | Python |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
if index = 67: | if index == 67: | Use == for comparison. | Python |
let list=vec![23,69,22]; let first=&list[0]; list.push(78); | let mut list=vec![23,69,22]; let first=list[0]; list.push(78); | Copy instead of reference. | Rust |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
class Item {{ int temp; }}
obj.temp=5; | class Item {{ public int temp; }}
obj.temp=5; | Make field public. | Java |
if a > 23
puts 'output' | if a > 23
puts 'output'
end | Add 'end'. | Ruby |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
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 |
for (x in data) | for (x of data) | for...in iterates keys. | JavaScript |
$temp = 6; if ($temp = 6) {{}} | $temp = 6; if ($temp == 6) {{}} | Use ==. | PHP |
SELECT * FROM items WHRE name=42; | SELECT * FROM items WHERE name=42; | Fix WHERE. | SQL |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
["test", 46] | ["test", 46] | Correct. | JSON |
$arr[40] = 5; | if (isset($arr[40])) $arr[40] = 5; | Check existence. | PHP |
cin >> data; | int data;
cin >> data; | Declare variable. | C++ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.