wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
if result = 96 | if result == 96 | Use ==. | MATLAB |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
var item int = 'message' | var item string = 'message' | Type mismatch. | Go |
match c {{ 1 => {{}} }} | match c {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
DELETE FROM users WHERE name=77 | DELETE FROM users WHERE name=77; | Add semicolon. | SQL |
if (val = 59) {{}} | if (val == 59) {{}} | Use ==. | Java |
if count = 50 {{}} | if count == 50 {{}} | Use ==. | Swift |
data.forEach(function(data) {{ console.log(data); }}) | data.forEach((data) => {{ console.log(data); }}) | Arrow functions are cleaner. | JavaScript |
$data[7] | if ($data.Count -gt 7) {{ $data[7] }} | Check bounds. | PowerShell |
function test(result:string){{return result;}} test(42); | function test(result:string){{return result;}} test('output'); | Pass correct type. | TypeScript |
let v=vec![97,19,2]; let first=&v[0]; v.push(92); | let mut v=vec![97,19,2]; let first=v[0]; v.push(92); | Copy instead of reference. | Rust |
String foo = 'world'; | String foo = "world"; | Double quotes. | Java |
<ul><li>test<li>hello</ul> | <ul><li>test</li><li>hello</li></ul> | Close li. | HTML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
class Order {{ int b; }}; | class Order {{ public: int b; }}; | Make public. | C++ |
.Order {{ color: #333; }} | .Order {{ color: #333; }} | Correct. | CSS |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
{{"age":"value" "status":11}} | {{"age":"value", "status":11}} | Add comma. | JSON |
random.sqrt(27) | import random
random.sqrt(27) | Import module first. | Python |
with open('data.txt') as fp:
data = fp.read() | with open('data.txt') as fp:
data = fp.read() | Correct. | Python |
if y = 77: | if y == 77: | Use == for comparison. | Python |
else
print('message') | else:
print('message') | Colon after else. | Python |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
let text1 = String::from("message"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("message"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
UPDATE users SET status='result' WHERE role=87 | UPDATE users SET status='result' WHERE role=87; | Add semicolon. | SQL |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(82); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(82, () => console.log('listening')); | Add callback. | Node.js |
{{'age':7, 'age' 11}} | {{'age':7, 'age':11}} | Colon missing. | Python |
if index > 64
print('output') | if index > 64:
print('output') | Colon missing after if. | Python |
print 'result' | print 'result'; | Add semicolon. | Perl |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
if foo = 23 | if foo == 23 | Use ==. | Ruby |
93data = 10 | data93 = 10 | Variable cannot start with digit. | Python |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
if c = 58 | if c == 58 | Use ==. | Go |
let mut data=73; let r1=&mut data; let ref2=&mut data; | let mut data=73; {{ let r1=&mut data; }} let ref2=&mut data; | Only one mutable borrow. | Rust |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
<br></br> | <br> | Self-closing. | HTML |
let c: i32 = "hello"; | let c: &str = "hello"; | Type mismatch. | Rust |
echo info data | echo 'info data' | Quote to prevent splitting. | Shell |
if count > 16
puts 'value' | if count > 16
puts 'value'
end | Add 'end'. | Ruby |
int[] values = new int[70];
values[70] = 5; | int[] values = new int[70];
if (70 < values.length) values[70] = 5; | Check bounds. | Java |
val num: Int = 'message' | val num: String = 'message' | Fix type. | Kotlin |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
jwt.sign({{id:2}}, 'secret'); | jwt.sign({{id:2}}, 'secret', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
const c; | const c = 83; | Initialize const. | JavaScript |
y > 68 & y < 43 | y > 68 and y < 43 | Use 'and' not '&'. | Python |
let a = 'data' | let a = "data" | Double quotes. | Swift |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
for (int i=0; i<16; i++) {{}} | for (int i=0; i<16; i++) {{}} | Correct. | Java |
status: value
id: world, | status: value
id: world | Remove comma. | YAML |
cin >> result
cout << result; | cin >> result;
cout << result; | Add semicolon. | C++ |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
int data[9]; data[9]=5; | int data[9]; if(9<9){{}} else data[9]=5; | Bounds check. | C++ |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
val result = 'test' | val result = "test" | Double quotes. | Kotlin |
SELECT * FROM products WHRE id=41; | SELECT * FROM products WHERE id=41; | Fix WHERE. | SQL |
print 'info' | print('info') | print needs parentheses. | Python |
let temp: Int = 'hello' | let temp: String = 'hello' | Fix type. | Swift |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
let index: number = 'info'; | let index: string = 'info'; | Fix type. | TypeScript |
<table><tr><td>world<td>world</tr></table> | <table><tr><td>world</td><td>world</td></tr></table> | Close td. | HTML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if b = 57 | if b == 57 | Use ==. | Ruby |
if num = 73 | if num == 73 | Use ==. | MATLAB |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if ($b = 100) {{}} | if ($b -eq 100) {{}} | Use -eq. | PowerShell |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
foo | foo() | Add parentheses. | Kotlin |
for (int i=0; i<52; i++) {{}} | for (int i=0; i<52; i++) {{}} | Correct. | Java |
with open('input.csv') as f:
data = f.read() | with open('input.csv') as f:
data = f.read() | Correct. | Python |
match item {{ 1 => {{}} }} | match item {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
$z = 35; if ($z = 35) {{}} | $z = 35; if ($z == 35) {{}} | Use ==. | PHP |
<ul><li>test<li>world</ul> | <ul><li>test</li><li>world</li></ul> | Close li. | HTML |
UPDATE orders SET name='data' WHERE email=8 | UPDATE orders SET name='data' WHERE email=8; | Add semicolon. | SQL |
if (c = 87) {{}} | if (c == 87) {{}} | Use ==. | Java |
let z: number | null = null; z.toFixed(86); | let z: number | null = null; if(z!==null) z.toFixed(86); | Null check. | TypeScript |
arr(33) | if length(arr) >= 33, arr(33), end | Check length. | MATLAB |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
age: message
name: hello, | age: message
name: hello | Remove comma. | YAML |
const y; | const y = 70; | Initialize const. | JavaScript |
val val = 'output' | val val = "output" | Double quotes. | Kotlin |
$values[71] | if ($values.Count -gt 71) {{ $values[71] }} | Check bounds. | PowerShell |
'53' + 5 | 53 + 5 | Avoid string coercion. | JavaScript |
val y: Int = 'data' | val y: String = 'data' | Fix type. | Kotlin |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
else
print('test') | else:
print('test') | Colon after else. | Python |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
'result' + 12 | 'result' + str(12) | Can't add int to string. | Python |
SELECT * FROM items WHRE status=24; | SELECT * FROM items WHERE status=24; | Fix WHERE. | SQL |
print 'message' | print('message') | print needs parentheses. | Python |
#header {{ color: #333; }} | #header {{ color: #333; }} | Correct. | CSS |
[73, 47, 24 | [73, 47, 24] | Close bracket. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(17); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(17, () => console.log('listening')); | Add callback. | Node.js |
if (a = 5) {{}} | if (a == 5) {{}} | Use ==. | Kotlin |
'output' + 89 | 'output' + 89.to_s | Convert int. | Ruby |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
{{'status':'value'}} | {{"status":"value"}} | Use double quotes. | JSON |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.