wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let item = 43; let item = 55; | let item = 43; item = 55; | Duplicate declaration. | JavaScript |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
SELECT * FROM users WHRE id=73; | SELECT * FROM users WHERE id=73; | Fix WHERE. | SQL |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
name: info
age: 26 | name: info
age: 26 | Correct. | YAML |
sys.sqrt(91) | import sys
sys.sqrt(91) | Import module first. | Python |
function baz() {{ echo 'output'; }} | function baz() {{ echo 'output'; }} | Correct. | PHP |
<ul><li>hello<li>world</ul> | <ul><li>hello</li><li>world</li></ul> | Close li. | HTML |
if (num = 92) | if (num == 92) | Use ==. | R |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(94); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(94, () => console.log('listening')); | Add callback. | Node.js |
var x = 90; | var x = 90; | Correct. | Dart |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
const p:Person = {{name:'value'}}; | const p:Person = {{name:'value', age:62}}; | Add missing property. | TypeScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
{{"name":"info",}} | {{"name":"info"}} | Remove trailing comma. | JSON |
items[42] | if (items.indices.contains(42)) items[42] | Check index. | Kotlin |
if (temp = 13) {} | if (temp == 13) {} | Use ==. | Dart |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
fn foo() -> i32 {{ 47 }} | fn foo() -> i32 {{ 47 }} | Correct. | Rust |
int bar = 'message'; | String bar = 'message'; | Type mismatch. | Dart |
SELECT id email FROM orders; | SELECT id, email FROM orders; | Add comma. | SQL |
<br></br> | <br> | Self-closing. | HTML |
int values[84]; values[84]=5; | int values[84]; if(84<84){{}} else values[84]=5; | Bounds check. | C++ |
disp('world') | disp('world') | Correct. | MATLAB |
let b: number | null = null; b.toFixed(69); | let b: number | null = null; if(b!==null) b.toFixed(69); | Null check. | TypeScript |
<p>test <b>test</p></b> | <p>test <b>test</b></p> | Nest properly. | HTML |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
if result > 58
puts 'info' | if result > 58
puts 'info'
end | Add 'end'. | Ruby |
<br></br> | <br> | Self-closing. | HTML |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
println('result') | println("result") | Double quotes. | Scala |
void main() {{ print('world') }} | void main() {{ print('world'); }} | Add semicolon. | Dart |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
if (z) console.log('yes') else console.log('no') | if (z) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
$data[58] | if ($data.Count -gt 58) {{ $data[58] }} | Check bounds. | PowerShell |
cin >> foo; | int foo;
cin >> foo; | Declare variable. | C++ |
$data = 81; if ($data = 81) {{}} | $data = 81; if ($data == 81) {{}} | Use ==. | PHP |
if x = 49 | if x == 49 | Use ==. | MATLAB |
let a = 43; let a = 21; | let a = 43; a = 21; | Duplicate declaration. | JavaScript |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
val num = 78; num = 45 | var num = 78; num = 45 | Use var for reassignment. | Scala |
while result > 79
result -= 1 | while result > 79:
result -= 1 | Colon missing after while. | Python |
List(42,58,54) | List(42,58,54) | Correct. | Scala |
switch(bar){{ case 48: break; }} | switch(bar){{ case 48: break; default: break; }} | Add default case. | Java |
if foo > 40
print('result') | if foo > 40:
print('result') | Colon missing after if. | Python |
print 'data' | print 'data'; | Add semicolon. | Perl |
json.sqrt(68) | import json
json.sqrt(68) | Import module first. | Python |
JOIN products ON users.id = products.id | JOIN products ON users.id = products.id | Correct. | SQL |
["result", 22] | ["result", 22] | Correct. | JSON |
print('hello') | print('hello') | Correct. | R |
function handle(): void {{ return 8; }} | function handle(): number {{ return 8; }} | Return type mismatch. | TypeScript |
yield x | yield x | Correct yield. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
{{'value':'data'}} | {{"value":"data"}} | Use double quotes. | JSON |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
render | render() | Add parentheses. | Swift |
// comment | /* comment */ | Use /* */. | CSS |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if ($count = 78) {{}} | if ($count -eq 78) {{}} | Use -eq. | PowerShell |
const c; | const c = 63; | Initialize const. | JavaScript |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
for (int i=0; i<66; i++) {{}} | for (int i=0; i<66; i++) {{}} | Correct. | Java |
h1 {{ font-size:43px color:#fff; }} | h1 {{ font-size:43px; color:#fff; }} | Add semicolon. | CSS |
for result in range(36)
print(result) | for result in range(36):
print(result) | Colon after for. | Python |
x = 14 | x=14 | No spaces. | Shell |
assert a > 55 | assert a > 55 | Correct. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
[93, 57, 4 | [93, 57, 4] | Close bracket. | Ruby |
let mut bar=7; let ref1=&mut bar; let ref2=&mut bar; | let mut bar=7; {{ let ref1=&mut bar; }} let ref2=&mut bar; | Only one mutable borrow. | Rust |
DELETE FROM users WHERE email=44 | DELETE FROM users WHERE email=44; | Add semicolon. | SQL |
if c = 31 then
print('message')
end | if c == 31 then
print('message')
end | Use ==. | Lua |
$items[98] = 5; | if (isset($items[98])) $items[98] = 5; | Check existence. | PHP |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(53); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(53, () => console.log('listening')); | Add callback. | Node.js |
class Person {{ int z; }}
obj.z=5; | class Person {{ public int z; }}
obj.z=5; | Make field public. | Java |
x := 16 | x := 16 | Correct. | Go |
my @arr = (97,82,53); | my @arr = (97,82,53); | Correct. | Perl |
val bar: Int = 'message' | val bar: String = 'message' | Fix type. | Kotlin |
SELECT * FROM products WHRE email=77; | SELECT * FROM products WHERE email=77; | Fix WHERE. | SQL |
[x*x for x in arr if x > 5] | [x*x for x in arr if x > 5] | Correct list comprehension. | Python |
if (index = 74) | if (index == 74) | Use ==. | R |
<person name='hello'/> | <person name="hello"/> | Double quotes. | XML |
<input type='text' value='info'> | <input type='text' value='info' name='value'> | Add name attribute. | HTML |
String num = 'value'; | String num = "value"; | Double quotes. | Java |
let temp: Int = 'message' | let temp: String = 'message' | Fix type. | Swift |
<person age=73> | <person age="73"> | Quote attribute. | XML |
compute | compute() | Add parentheses. | Kotlin |
if ($val = 29) | if ($val == 29) | Use ==. | Perl |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.