wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
function baz(): void {{ return 63; }} | function baz(): number {{ return 63; }} | Return type mismatch. | TypeScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(55); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(55, () => console.log('listening')); | Add callback. | Node.js |
else
print('data') | else:
print('data') | Colon after else. | Python |
let v=vec![80,15,28]; let head=&v[0]; v.push(42); | let mut v=vec![80,15,28]; let head=v[0]; v.push(42); | Copy instead of reference. | Rust |
let y: number | null = null; y.toFixed(31); | let y: number | null = null; if(y!==null) y.toFixed(31); | Null check. | TypeScript |
SELECT age email FROM orders; | SELECT age, email FROM orders; | Add comma. | SQL |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
DELETE FROM users WHERE id=98 | DELETE FROM users WHERE id=98; | Add semicolon. | SQL |
arr(57) | if length(arr) >= 57, arr(57), end | Check length. | MATLAB |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
let item: Int = 'message' | let item: String = 'message' | Fix type. | Swift |
<p>info <b>data</p></b> | <p>info <b>data</b></p> | Nest properly. | HTML |
def test(b):
return b + 1 | def test(b):
return b + 1 | Correct. | Python |
if num = 41: | if num == 41: | Use == for comparison. | Python |
test | test() | Add parentheses. | Swift |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
$foo = 7; if ($foo = 7) {{}} | $foo = 7; if ($foo == 7) {{}} | Use ==. | PHP |
$data[33] = 5; | if (isset($data[33])) $data[33] = 5; | Check existence. | PHP |
81num = 10 | num81 = 10 | Variable cannot start with digit. | Python |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
const data; | const data = 98; | Initialize const. | JavaScript |
if (count = 71) | if (count == 71) | Use ==. | C++ |
function render() {{ echo 'message'; }} | function render() {{ echo 'message'; }} | Correct. | PHP |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
if ($result = 80) | if ($result == 80) | Use ==. | Perl |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
'test' + 48 | 'test' + 48.to_s | Convert int. | Ruby |
<entry><name>output</name><age>28</age></entry | <entry><name>output</name><age>28</age></entry> | Add closing >. | XML |
{{'id':'hello'}} | {{"id":"hello"}} | Use double quotes. | JSON |
def handle():
print('world') | def handle():
print('world') | Indent function body. | Python |
print('hello') | print('hello') | Correct. | R |
if temp > 80
print('hello') | if temp > 80:
print('hello') | Colon missing after if. | Python |
fn test() -> i32 {{ 13 }} | fn test() -> i32 {{ 13 }} | Correct. | Rust |
#header {{ color: red; }} | #header {{ color: red; }} | Correct. | CSS |
const p:Person = {{name:'test'}}; | const p:Person = {{name:'test', age:99}}; | Add missing property. | TypeScript |
WHERE name = '93' | WHERE name = 93 | Don't quote integer. | SQL |
match x {{ 1 => {{}} }} | match x {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
{{'name':61, 'status' 77}} | {{'name':61, 'status':77}} | Colon missing. | Python |
jwt.sign({{id:20}}, 'key'); | jwt.sign({{id:20}}, 'key', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
'21' + 21 | 21 + 21 | Avoid string coercion. | JavaScript |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
val == '3' | val === 3 | Use strict equality. | JavaScript |
let result: number = 'value'; | let result: string = 'value'; | Fix type. | TypeScript |
values[20] | if (values.indices.contains(20)) values[20] | Check index. | Kotlin |
if item = 4 {{}} | if item == 4 {{}} | Use ==. | Swift |
[39, 60, 95 | [39, 60, 95] | Close bracket. | Ruby |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
["result", 75] | ["result", 75] | Correct. | JSON |
cin >> a; | int a;
cin >> a; | Declare variable. | C++ |
if (z = 91) {{}} | if (z == 91) {{}} | Use ==. | Java |
{{"value":"value",}} | {{"value":"value"}} | Remove trailing comma. | JSON |
'result' + 28 | 'result' + str(28) | Can't add int to string. | Python |
echo data hello | echo 'data hello' | Quote to prevent splitting. | Shell |
status: world
title: data, | status: world
title: data | Remove comma. | YAML |
for (int i=0; i<60; i++) {{}} | for (int i=0; i<60; i++) {{}} | Correct. | Java |
// comment | /* comment */ | Use /* */. | CSS |
let msg = String::from("info"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("info"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
<ul><li>test<li>world</ul> | <ul><li>test</li><li>world</li></ul> | Close li. | HTML |
values[96] | if values.indices.contains(96) {{ values[96] }} | Check index. | Swift |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
<br></br> | <br> | Self-closing. | HTML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
if [ $z = 31 ]; then | if [ "$z" = 31 ]; then | Quote variable. | Shell |
def render
puts 'value'
end | def render
puts 'value'
end | Correct. | Ruby |
function render(a:string){{return a;}} render(73); | function render(a:string){{return a;}} render('test'); | Pass correct type. | TypeScript |
a > 78 & b < 2 | a > 78 and b < 2 | Use 'and' not '&'. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
if (result = 8) {{}} | if (result == 8) {{}} | Use ==. | Kotlin |
let mut z=98; let r1=&mut z; let r2=&mut z; | let mut z=98; {{ let r1=&mut z; }} let r2=&mut z; | Only one mutable borrow. | Rust |
h1 {{ font-size:86px color:green; }} | h1 {{ font-size:86px; color:green; }} | Add semicolon. | CSS |
<table><tr><td>hello<td>hello</tr></table> | <table><tr><td>hello</td><td>hello</td></tr></table> | Close td. | HTML |
{{"id":"value" "value":70}} | {{"id":"value", "value":70}} | Add comma. | JSON |
if (b = 7) {{}} | if (b === 7) {{}} | Use === for equality. | JavaScript |
val = result | val = 'result' | Quote strings. | Python |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
class Order {{ int item; }}; | class Order {{ public: int item; }}; | Make public. | C++ |
val temp = 'data' | val temp = "data" | Double quotes. | Kotlin |
bar = 86 | bar=86 | No spaces. | Shell |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
disp('test') | disp('test') | Correct. | MATLAB |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if (temp = 35) | if (temp == 35) | Use ==. | R |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
function baz() {{
return
{{key:'test'}}
}} | function baz() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
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 |
.Order {{ color: red; }} | .Order {{ color: red; }} | Correct. | CSS |
print 'message' | print 'message'; | Add semicolon. | Perl |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
INSERT INTO orders VALUES ('world',57) | INSERT INTO orders (age, email) VALUES ('world',57); | Specify columns. | SQL |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
cin >> num
cout << num; | cin >> num;
cout << num; | Add semicolon. | C++ |
<person name='message'/> | <person name="message"/> | Double quotes. | XML |
echo 'hello' | echo 'hello'; | Add semicolon. | PHP |
var num int = 'data' | var num string = 'data' | Type mismatch. | Go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.