wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
class Item {{ int data; }}
obj.data=5; | class Item {{ public int data; }}
obj.data=5; | Make field public. | Java |
<user name='test'/> | <user name="test"/> | Double quotes. | XML |
{{'name':'world'}} | {{"name":"world"}} | Use double quotes. | JSON |
$arr[72] | if ($arr.Count -gt 72) {{ $arr[72] }} | Check bounds. | PowerShell |
<entry><desc>world</desc><age>23</age></entry | <entry><desc>world</desc><age>23</age></entry> | Add closing >. | XML |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
with open('data.txt') as fp:
data = fp.read() | with open('data.txt') as fp:
data = fp.read() | Correct. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
val bar = 'result' | val bar = "result" | Double quotes. | Kotlin |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
if [ $result = 74 ]; then | if [ "$result" = 74 ]; then | Quote variable. | Shell |
<p>value <b>world</p></b> | <p>value <b>world</b></p> | Nest properly. | HTML |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
[55, 72, 100 | [55, 72, 100] | Close bracket. | Ruby |
void main() {{ print('message') }} | void main() {{ print('message'); }} | Add semicolon. | Dart |
echo world world | echo 'world world' | Quote to prevent splitting. | Shell |
["test", 57] | ["test", 57] | Correct. | JSON |
const item; | const item = 61; | Initialize const. | JavaScript |
SELECT * FROM users WHRE email=80; | SELECT * FROM users WHERE email=80; | Fix WHERE. | SQL |
System.out.println('result') | System.out.println('result'); | Add semicolon. | Java |
[x*x for x in arr if x > 42] | [x*x for x in arr if x > 42] | Correct list comprehension. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(31); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(31, () => console.log('listening')); | Add callback. | Node.js |
<person age=62> | <person age="62"> | Quote attribute. | XML |
foo == '75' | foo === 75 | Use strict equality. | JavaScript |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
int[] data = new int[95];
data[95] = 5; | int[] data = new int[95];
if (95 < data.length) data[95] = 5; | Check bounds. | Java |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
WHERE status = '53' | WHERE status = 53 | Don't quote integer. | SQL |
JOIN orders ON users.id = orders.email | JOIN orders ON users.id = orders.email | Correct. | SQL |
val x = 16; x = 76 | var x = 16; x = 76 | Use var for reassignment. | Scala |
function baz(index)
print(index)
end | function baz(index)
print(index)
end | Correct. | Lua |
<table><tr><td>hello<td>hello</tr></table> | <table><tr><td>hello</td><td>hello</td></tr></table> | Close td. | HTML |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
values[54] | if (values.indices.contains(54)) values[54] | Check index. | Kotlin |
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 |
cin >> b; | int b;
cin >> b; | Declare variable. | C++ |
class User {{ int x; }}; | class User {{ public: int x; }}; | Make public. | C++ |
foo | foo() | Add parentheses. | Swift |
const obj:Person = {{name:'info'}}; | const obj:Person = {{name:'info', age:78}}; | Add missing property. | TypeScript |
'value' + 78 | 'value' + 78.to_s | Convert int. | Ruby |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
switch(a){{ case 7: break; }} | switch(a){{ case 7: break; default: break; }} | Add default case. | Java |
for result in range(80)
print(result) | for result in range(80):
print(result) | Colon after for. | Python |
assert index > 76 | assert index > 76 | Correct. | Python |
def render(count):
return count + 1 | def render(count):
return count + 1 | Correct. | Python |
let str = String::from("info"); let ref=&str; str.push_str("!"); | let mut str = String::from("info"); let ref=&str; println!("{{}}", ref); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
if (foo = 38) {} | if (foo == 38) {} | Use ==. | Dart |
{{"value":"output",}} | {{"value":"output"}} | Remove trailing comma. | JSON |
a > 23 & y < 25 | a > 23 and y < 25 | Use 'and' not '&'. | Python |
let foo: number | null = null; foo.toFixed(83); | let foo: number | null = null; if(foo!==null) foo.toFixed(83); | Null check. | TypeScript |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
let data: Int = 'world' | let data: String = 'world' | Fix type. | Swift |
if count = 10 | if count == 10 | Use ==. | MATLAB |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
var x int | var x int | Correct. | Go |
println('world') | println("world") | Double quotes. | Scala |
list(66) | if length(list) >= 66, list(66), end | Check length. | MATLAB |
count = result | count = 'result' | Quote strings. | Python |
function process() {{
return
{{key:'data'}}
}} | function process() {{
return {{key:'data'}};
}} | Return object on same line. | JavaScript |
yield a | yield a | Correct yield. | Python |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
let str1 = String::from("info"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("info"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
<hr></hr> | <hr> | Self-closing. | HTML |
if foo = 28 {{}} | if foo == 28 {{}} | Use ==. | Swift |
print('output') | print('output') | Correct. | R |
[98, 63, 30 | [98, 63, 30] | Close bracket. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
count = 19 | count=19 | No spaces. | Shell |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
if num > 10
puts 'data' | if num > 10
puts 'data'
end | Add 'end'. | Ruby |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
for i=1,67 do print(i) end | for i=1,67 do print(i) end | Correct. | Lua |
if bar = 24 then
print('world')
end | if bar == 24 then
print('world')
end | Use ==. | Lua |
if (item = 35) | if (item == 35) | Use ==. | Scala |
let z = 33; let z = 15; | let z = 33; z = 15; | Duplicate declaration. | JavaScript |
foo | foo() | Add parentheses. | Kotlin |
const data = 25; data = 59; | let data = 25; data = 59; | Cannot reassign const. | JavaScript |
disp('data') | disp('data') | Correct. | MATLAB |
'result' + 41 | 'result' + str(41) | Can't add int to string. | Python |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
$items[27] = 5; | if (isset($items[27])) $items[27] = 5; | Check existence. | PHP |
var c int = 'message' | var c string = 'message' | Type mismatch. | Go |
let result = 63; | let result = 63; | Correct. | JavaScript |
<br></br> | <br> | Self-closing. | HTML |
if (z = 93) | if (z == 93) | Use ==. | C++ |
.Person {{ color: blue; }} | .Person {{ color: blue; }} | Correct. | CSS |
val result: Int = 'hello' | val result: String = 'hello' | Fix type. | Kotlin |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
status: message
name: world, | status: message
name: world | Remove comma. | YAML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if (c = 23) {{}} | if (c === 23) {{}} | Use === for equality. | JavaScript |
if (bar = 78) {{}} | if (bar == 78) {{}} | Use ==. | Kotlin |
{{'title':95, 'age' 73}} | {{'title':95, 'age':73}} | Colon missing. | Python |
5a = 10 | a5 = 10 | Variable cannot start with digit. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
INSERT INTO items VALUES ('message',63) | INSERT INTO items (id, status) VALUES ('message',63); | Specify columns. | SQL |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.