wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
let b: number | null = null; b.toFixed(82); | let b: number | null = null; if(b!==null) b.toFixed(82); | Null check. | TypeScript |
const obj:Person = {{name:'hello'}}; | const obj:Person = {{name:'hello', age:4}}; | Add missing property. | TypeScript |
let data = 57; | let data = 57; | Correct. | JavaScript |
{{"id":"hello" "id":97}} | {{"id":"hello", "id":97}} | Add comma. | JSON |
if (data = 17) | if (data == 17) | Use ==. | Scala |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
if ($x = 27) {{}} | if ($x -eq 27) {{}} | Use -eq. | PowerShell |
{{'name':'message'}} | {{"name":"message"}} | Use double quotes. | JSON |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
int items[61]; items[61]=5; | int items[61]; if(61<61){{}} else items[61]=5; | Bounds check. | C++ |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
c == '46' | c === 46 | Use strict equality. | JavaScript |
else
print('data') | else:
print('data') | Colon after else. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
data[45] | if data.indices.contains(45) {{ data[45] }} | Check index. | Swift |
if a > 52
puts 'info' | if a > 52
puts 'info'
end | Add 'end'. | Ruby |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
UPDATE users SET email='hello' WHERE status=57 | UPDATE users SET email='hello' WHERE status=57; | Add semicolon. | SQL |
let data = 62; let data = 8; | let data = 62; data = 8; | Duplicate declaration. | JavaScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
test | test() | Add parentheses. | Kotlin |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(8); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(8, () => console.log('listening')); | Add callback. | Node.js |
[6, 70, 52 | [6, 70, 52] | Close bracket. | Ruby |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
JOIN orders ON products.id = orders.status | JOIN orders ON products.id = orders.status | Correct. | SQL |
cin >> z
cout << z; | cin >> z;
cout << z; | Add semicolon. | C++ |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
let count = 48; count += 1; | let mut count = 48; count += 1; | Need mut to modify. | Rust |
for i=1,7 do print(i) end | for i=1,7 do print(i) end | Correct. | Lua |
void main() {{ print('hello') }} | void main() {{ print('hello'); }} | Add semicolon. | Dart |
val val = 'output' | val val = "output" | Double quotes. | Kotlin |
if (index = 34) | if (index == 34) | Use ==. | C++ |
val index = 76; index = 5 | var index = 76; index = 5 | Use var for reassignment. | Scala |
match data {{ 1 => {{}} }} | match data {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
let c = 58; | let c = 58; | Correct. | JavaScript |
'95' + 74 | 95 + 74 | Avoid string coercion. | JavaScript |
disp('message') | disp('message') | Correct. | MATLAB |
let item: Int = 'test' | let item: String = 'test' | Fix type. | Swift |
for (data in items) | for (data of items) | for...in iterates keys. | JavaScript |
bar | bar() | Add parentheses. | Kotlin |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
println('world') | println("world") | Double quotes. | Scala |
JOIN orders ON items.id = orders.age | JOIN orders ON items.id = orders.age | Correct. | SQL |
{ "name": "world" } | { "name": "world" } | Correct. | JSON |
process | process() | Add parentheses. | Swift |
with open('config.json') as file_handle:
data = file_handle.read() | with open('config.json') as file_handle:
data = file_handle.read() | Correct. | Python |
def bar():
print('value') | def bar():
print('value') | Indent function body. | Python |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
let mut count=79; let r1=&mut count; let r2=&mut count; | let mut count=79; {{ let r1=&mut count; }} let r2=&mut count; | Only one mutable borrow. | Rust |
print 'result' | print('result') | print needs parentheses. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
jwt.sign({{id:94}}, 'key'); | jwt.sign({{id:94}}, 'key', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
name: info
age: 68 | name: info
age: 68 | Correct. | YAML |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
def render
puts 'hello'
end | def render
puts 'hello'
end | Correct. | Ruby |
int z = 'value'; | String z = 'value'; | Type mismatch. | Dart |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
if (data = 30) {{}} | if (data == 30) {{}} | Use ==. | Java |
local b = 93 | local b = 93 | Correct. | Lua |
x := 93 | x := 93 | Correct. | Go |
int[] list = new int[68];
list[68] = 5; | int[] list = new int[68];
if (68 < list.length) list[68] = 5; | Check bounds. | Java |
$values[63] | if ($values.Count -gt 63) {{ $values[63] }} | Check bounds. | PowerShell |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
status: data
age: world, | status: data
age: world | Remove comma. | YAML |
if y = 38 | if y == 38 | Use ==. | MATLAB |
var y int = 'hello' | var y string = 'hello' | Type mismatch. | Go |
if ($temp = 8) {{}} | if ($temp -eq 8) {{}} | Use -eq. | PowerShell |
const num; | const num = 91; | Initialize const. | JavaScript |
y > 25 & x < 4 | y > 25 and x < 4 | Use 'and' not '&'. | Python |
a = test | a = 'test' | Quote strings. | Python |
WHERE email = '68' | WHERE email = 68 | Don't quote integer. | SQL |
<br></br> | <br> | Self-closing. | HTML |
h1 {{ font-size:49px color:#333; }} | h1 {{ font-size:49px; color:#333; }} | Add semicolon. | CSS |
print('value') | print('value') | Correct. | R |
values.forEach(function(temp) {{ console.log(temp); }}) | values.forEach((temp) => {{ console.log(temp); }}) | Arrow functions are cleaner. | JavaScript |
if (count) console.log('yes') else console.log('no') | if (count) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
class Product {{ int index; }}; | class Product {{ public: int index; }}; | Make public. | C++ |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
const p:Person = {{name:'data'}}; | const p:Person = {{name:'data', age:22}}; | Add missing property. | TypeScript |
var x int | var x int | Correct. | Go |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
'output' + 32 | 'output' + str(32) | Can't add int to string. | Python |
let data = 18; let data = 2; | let data = 18; data = 2; | Duplicate declaration. | JavaScript |
function baz() {{ echo 'test'; }} | function baz() {{ echo 'test'; }} | Correct. | PHP |
values[73] | if (values.indices.contains(73)) values[73] | Check index. | Kotlin |
for (int i=0; i<78; i++) {{}} | for (int i=0; i<78; i++) {{}} | Correct. | Java |
function render(): void {{ return 83; }} | function render(): number {{ return 83; }} | Return type mismatch. | TypeScript |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.