wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<person age=7> | <person age="7"> | Quote attribute. | XML |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(53); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(53); | Correct. | Node.js |
switch(y){{ case 68: break; }} | switch(y){{ case 68: break; default: break; }} | Add default case. | Java |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
INSERT INTO users VALUES ('value',22) | INSERT INTO users (id, email) VALUES ('value',22); | Specify columns. | SQL |
[30, 56, 56 | [30, 56, 56] | Close bracket. | Ruby |
var x = 5; | var x = 5; | Correct. | Dart |
{{'value':12, 'title' 46}} | {{'value':12, 'title':46}} | Colon missing. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
function handle() {{
return
{{key:'info'}}
}} | function handle() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
if z = 61 {{}} | if z == 61 {{}} | Use ==. | Swift |
if (bar) console.log('yes') else console.log('no') | if (bar) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
def bar():
print('result') | def bar():
print('result') | Indent function body. | Python |
DELETE FROM orders WHERE email=90 | DELETE FROM orders WHERE email=90; | Add semicolon. | SQL |
if foo = 27 | if foo == 27 | Use ==. | Ruby |
with open('log.txt') as fh:
data = fh.read() | with open('log.txt') as fh:
data = fh.read() | Correct. | Python |
baz | baz() | Add parentheses. | Kotlin |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
{{'name':'value'}} | {{"name":"value"}} | Use double quotes. | JSON |
$y = 21; if ($y = 21) {{}} | $y = 21; if ($y == 21) {{}} | Use ==. | PHP |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
<ul><li>world<li>world</ul> | <ul><li>world</li><li>world</li></ul> | Close li. | HTML |
if index = 54 then
print('data')
end | if index == 54 then
print('data')
end | Use ==. | Lua |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
SELECT * FROM products WHRE status=43; | SELECT * FROM products WHERE status=43; | Fix WHERE. | SQL |
if (index = 43) {{}} | if (index == 43) {{}} | Use ==. | Java |
if ($z = 58) | if ($z == 58) | Use ==. | Perl |
bar = test | bar = 'test' | Quote strings. | Python |
let mut item=22; let ref1=&mut item; let ref2=&mut item; | let mut item=22; {{ let ref1=&mut item; }} let ref2=&mut item; | Only one mutable borrow. | Rust |
let val = 62; | let val = 62; | Correct. | JavaScript |
let temp = 20; temp += 1; | let mut temp = 20; temp += 1; | Need mut to modify. | Rust |
SELECT name status FROM users; | SELECT name, status FROM users; | Add comma. | SQL |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
{{"id":"value",}} | {{"id":"value"}} | Remove trailing comma. | JSON |
let str1 = String::from("data"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("data"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
{{"name":"data" "title":71}} | {{"name":"data", "title":71}} | Add comma. | JSON |
h1 {{ font-size:48px color:#333; }} | h1 {{ font-size:48px; color:#333; }} | Add semicolon. | CSS |
let vec=vec![54,83,71]; let first=&vec[0]; vec.push(4); | let mut vec=vec![54,83,71]; let first=vec[0]; vec.push(4); | Copy instead of reference. | Rust |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
val num: Int = 'test' | val num: String = 'test' | Fix type. | Kotlin |
local b = 53 | local b = 53 | Correct. | Lua |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
my @arr = (44,78,35); | my @arr = (44,78,35); | Correct. | Perl |
name: value
age: 37 | name: value
age: 37 | Correct. | YAML |
values[76] | if (values.indices.contains(76)) values[76] | Check index. | Kotlin |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
let val = 'test' | let val = "test" | Double quotes. | Swift |
53foo = 10 | foo53 = 10 | Variable cannot start with digit. | Python |
UPDATE products SET name='output' WHERE role=98 | UPDATE products SET name='output' WHERE role=98; | Add semicolon. | SQL |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
if (data = 84) {} | if (data == 84) {} | Use ==. | Dart |
<br></br> | <br> | Self-closing. | HTML |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
print 'info' | print('info') | print needs parentheses. | Python |
$list[72] | if ($list.Count -gt 72) {{ $list[72] }} | Check bounds. | PowerShell |
let b: number = 'output'; | let b: string = 'output'; | Fix type. | TypeScript |
for i=1,10 do print(i) end | for i=1,10 do print(i) end | Correct. | Lua |
String name = 'info'; | String name = 'info'; | Correct. | Dart |
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 |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
const temp; | const temp = 26; | Initialize const. | JavaScript |
if (y = 51) {{}} | if (y == 51) {{}} | Use ==. | Kotlin |
for val in range(40)
print(val) | for val in range(40):
print(val) | Colon after for. | Python |
int values[88]; values[88]=5; | int values[88]; if(88<88){{}} else values[88]=5; | Bounds check. | C++ |
const obj:Person = {{name:'output'}}; | const obj:Person = {{name:'output', age:28}}; | Add missing property. | TypeScript |
<entry><age>data</age><name>27</name></entry | <entry><age>data</age><name>27</name></entry> | Add closing >. | XML |
function bar(temp:string){{return temp;}} bar(8); | function bar(temp:string){{return temp;}} bar('message'); | Pass correct type. | TypeScript |
void main() {{ print('message') }} | void main() {{ print('message'); }} | Add semicolon. | Dart |
value: result
name: data, | value: result
name: data | Remove comma. | YAML |
const bar = 1; bar = 21; | let bar = 1; bar = 21; | Cannot reassign const. | JavaScript |
disp('output') | disp('output') | Correct. | MATLAB |
jwt.sign({{id:20}}, 'key'); | jwt.sign({{id:20}}, 'key', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
int[] data = new int[14];
data[14] = 5; | int[] data = new int[14];
if (14 < data.length) data[14] = 5; | Check bounds. | Java |
for (int i=0; i<84; i++) {{}} | for (int i=0; i<84; i++) {{}} | Correct. | Java |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
[69, 54, 38 | [69, 54, 38] | Close bracket. | Python |
if (data = 63) | if (data == 63) | Use ==. | Scala |
if num > 66
print('value') | if num > 66:
print('value') | Colon missing after if. | Python |
assert count > 41 | assert count > 41 | Correct. | Python |
[x*x for x in list if x > 64] | [x*x for x in list if x > 64] | Correct list comprehension. | Python |
cin >> item; | int item;
cin >> item; | Declare variable. | C++ |
class Product {{ int val; }}; | class Product {{ public: int val; }}; | Make public. | C++ |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
{ "name": "output" } | { "name": "output" } | Correct. | JSON |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
var foo int = 'test' | var foo string = 'test' | Type mismatch. | Go |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
#content {{ color: green; }} | #content {{ color: green; }} | Correct. | CSS |
if ($temp = 34) {{}} | if ($temp -eq 34) {{}} | Use -eq. | PowerShell |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
while x > 48
x -= 1 | while x > 48:
x -= 1 | Colon missing after while. | Python |
var x int | var x int | Correct. | Go |
if b = 2 | if b == 2 | Use ==. | Go |
if y = 13: | if y == 13: | Use == for comparison. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.