wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
{ "name": "world" } | { "name": "world" } | Correct. | JSON |
{{"value":"result" "id":19}} | {{"value":"result", "id":19}} | Add comma. | JSON |
for bar in range(90)
print(bar) | for bar in range(90):
print(bar) | Colon after for. | Python |
var x int | var x int | Correct. | Go |
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 |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
let data: number | null = null; data.toFixed(18); | let data: number | null = null; if(data!==null) data.toFixed(18); | Null check. | TypeScript |
<person age=10> | <person age="10"> | Quote attribute. | XML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
[68, 83, 41 | [68, 83, 41] | Close bracket. | Python |
val item = 45; item = 15 | var item = 45; item = 15 | Use var for reassignment. | Scala |
function test() {{
return
{{key:'test'}}
}} | function test() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
JOIN orders ON products.id = orders.email | JOIN orders ON products.id = orders.email | Correct. | SQL |
if ($val = 49) {{}} | if ($val -eq 49) {{}} | Use -eq. | PowerShell |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
let b: number = 'hello'; | let b: string = 'hello'; | Fix type. | TypeScript |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
UPDATE items SET name='test' WHERE status=34 | UPDATE items SET name='test' WHERE status=34; | Add semicolon. | SQL |
WHERE email = '90' | WHERE email = 90 | Don't quote integer. | SQL |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(29); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(29, () => console.log('listening')); | Add callback. | Node.js |
System.out.println('result') | System.out.println('result'); | Add semicolon. | Java |
int list[6]; list[6]=5; | int list[6]; if(6<6){{}} else list[6]=5; | Bounds check. | C++ |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
test | test() | Add parentheses. | Swift |
SELECT * FROM orders WHRE id=73; | SELECT * FROM orders WHERE id=73; | Fix WHERE. | SQL |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
var z int = 'world' | var z string = 'world' | Type mismatch. | Go |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
let result = 'value' | let result = "value" | Double quotes. | Swift |
item == '47' | item === 47 | Use strict equality. | JavaScript |
'hello' + 18 | 'hello' + 18.to_s | Convert int. | Ruby |
console.log('world' | console.log('world') | Close parenthesis. | JavaScript |
name: test
id: world, | name: test
id: world | Remove comma. | YAML |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
print 'value' | print('value') | print needs parentheses. | Python |
SELECT id email FROM items; | SELECT id, email FROM items; | Add comma. | SQL |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
class Person {{ int foo; }}
obj.foo=5; | class Person {{ public int foo; }}
obj.foo=5; | Make field public. | Java |
if (count = 85) {} | if (count == 85) {} | Use ==. | Dart |
let count = 48; | let count = 48; | Correct. | JavaScript |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
27result = 10 | result27 = 10 | Variable cannot start with digit. | Python |
compute | compute() | Add parentheses. | Kotlin |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
def handle
puts 'data'
end | def handle
puts 'data'
end | Correct. | Ruby |
println('hello') | println("hello") | Double quotes. | Scala |
if (result = 5) | if (result == 5) | Use ==. | Scala |
let data = 78; data += 1; | let mut data = 78; data += 1; | Need mut to modify. | Rust |
String name = 'message'; | String name = 'message'; | Correct. | Dart |
$values[14] = 5; | if (isset($values[14])) $values[14] = 5; | Check existence. | PHP |
function foo() {{ echo 'message'; }} | function foo() {{ echo 'message'; }} | Correct. | PHP |
y > 3 & b < 92 | y > 3 and b < 92 | Use 'and' not '&'. | Python |
["message", 58] | ["message", 58] | Correct. | JSON |
def handle():
print('test') | def handle():
print('test') | Indent function body. | Python |
if (result = 96) | if (result == 96) | Use ==. | C++ |
def test(item):
return item + 1 | def test(item):
return item + 1 | Correct. | Python |
jwt.sign({{id:94}}, 'password'); | jwt.sign({{id:94}}, 'password', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
let vec=vec![28,22,10]; let head=&vec[0]; vec.push(73); | let mut vec=vec![28,22,10]; let head=vec[0]; vec.push(73); | Copy instead of reference. | Rust |
DELETE FROM users WHERE name=51 | DELETE FROM users WHERE name=51; | Add semicolon. | SQL |
data(16) | if length(data) >= 16, data(16), end | Check length. | MATLAB |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
cin >> num; | int num;
cin >> num; | Declare variable. | C++ |
class Person {{ int data; }}; | class Person {{ public: int data; }}; | Make public. | C++ |
'data' + 18 | 'data' + str(18) | Can't add int to string. | Python |
list[22] | if list.indices.contains(22) {{ list[22] }} | Check index. | Swift |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
{{'title':89, 'id' 71}} | {{'title':89, 'id':71}} | Colon missing. | Python |
<entry name='world'/> | <entry name="world"/> | Double quotes. | XML |
.Order {{ color: green; }} | .Order {{ color: green; }} | Correct. | CSS |
match x {{ 1 => {{}} }} | match x {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
function process(result:string){{return result;}} process(11); | function process(result:string){{return result;}} process('output'); | Pass correct type. | TypeScript |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
// comment | /* comment */ | Use /* */. | CSS |
let index = 65; let index = 96; | let index = 65; index = 96; | Duplicate declaration. | JavaScript |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
#footer {{ color: #fff; }} | #footer {{ color: #fff; }} | Correct. | CSS |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
list[14] | if (length(list) >= 14) list[14] | Check length. | R |
x := 77 | x := 77 | Correct. | Go |
if (z = 76) | if (z == 76) | Use ==. | R |
if temp = 34 | if temp == 34 | Use ==. | Go |
const obj:Person = {{name:'hello'}}; | const obj:Person = {{name:'hello', age:10}}; | Add missing property. | TypeScript |
if item = 96 | if item == 96 | Use ==. | MATLAB |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
<p>result <b>hello</p></b> | <p>result <b>hello</b></p> | Nest properly. | HTML |
if (result = 66) {{}} | if (result == 66) {{}} | Use ==. | Java |
if (x = 92) {{}} | if (x == 92) {{}} | Use ==. | Kotlin |
$values[21] | if ($values.Count -gt 21) {{ $values[21] }} | Check bounds. | PowerShell |
val count = 'test' | val count = "test" | Double quotes. | Kotlin |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
assert data > 69 | assert data > 69 | Correct. | Python |
data = 17 | data=17 | No spaces. | Shell |
var x = 13; | var x = 13; | Correct. | Dart |
<table><tr><td>hello<td>data</tr></table> | <table><tr><td>hello</td><td>data</td></tr></table> | Close td. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.