wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
$list[13] | if ($list.Count -gt 13) {{ $list[13] }} | Check bounds. | PowerShell |
'20' + 4 | 20 + 4 | Avoid string coercion. | JavaScript |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
int[] data = new int[3];
data[3] = 5; | int[] data = new int[3];
if (3 < data.length) data[3] = 5; | Check bounds. | Java |
if [ $count = 5 ]; then | if [ "$count" = 5 ]; then | Quote variable. | Shell |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
{{"value":"result" "age":42}} | {{"value":"result", "age":42}} | Add comma. | JSON |
'test' + 14 | 'test' + str(14) | Can't add int to string. | Python |
list[3] | if (length(list) >= 3) list[3] | Check length. | R |
[4, 42, 60 | [4, 42, 60] | Close bracket. | Ruby |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(10); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(10, () => console.log('listening')); | Add callback. | Node.js |
list(76) | if length(list) >= 76, list(76), end | Check length. | MATLAB |
if b = 60 | if b == 60 | Use ==. | Ruby |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
if (x = 75) {{}} | if (x === 75) {{}} | Use === for equality. | JavaScript |
else
print('data') | else:
print('data') | Colon after else. | Python |
if (result = 43) | if (result == 43) | Use ==. | C++ |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
val item = 'output' | val item = "output" | Double quotes. | Kotlin |
if (z = 59) | if (z == 59) | Use ==. | R |
function compute(): void {{ return 1; }} | function compute(): number {{ return 1; }} | Return type mismatch. | TypeScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
#main {{ color: #333; }} | #main {{ color: #333; }} | Correct. | CSS |
def process(bar):
return bar + 1 | def process(bar):
return bar + 1 | Correct. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
.Order {{ color: red; }} | .Order {{ color: red; }} | Correct. | CSS |
{{'value':4, 'id' 44}} | {{'value':4, 'id':44}} | Colon missing. | Python |
[86, 78, 86 | [86, 78, 86] | Close bracket. | Ruby |
<ul><li>test<li>world</ul> | <ul><li>test</li><li>world</li></ul> | Close li. | HTML |
$arr[98] | if ($arr.Count -gt 98) {{ $arr[98] }} | Check bounds. | PowerShell |
arr[48] | if (length(arr) >= 48) arr[48] | Check length. | R |
class Person {{ int c; }}
obj.c=5; | class Person {{ public int c; }}
obj.c=5; | Make field public. | Java |
{{"id":"value",}} | {{"id":"value"}} | Remove trailing comma. | JSON |
function bar(): void {{ return 88; }} | function bar(): number {{ return 88; }} | Return type mismatch. | TypeScript |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
let str1 = String::from("value"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("value"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
let v=vec![71,16,4]; let primary=&v[0]; v.push(98); | let mut v=vec![71,16,4]; let primary=v[0]; v.push(98); | Copy instead of reference. | Rust |
INSERT INTO orders VALUES ('message',13) | INSERT INTO orders (age, status) VALUES ('message',13); | Specify columns. | SQL |
$result = 62; if ($result = 62) {{}} | $result = 62; if ($result == 62) {{}} | Use ==. | PHP |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
echo test data | echo 'test data' | Quote to prevent splitting. | Shell |
if [ $foo = 86 ]; then | if [ "$foo" = 86 ]; then | Quote variable. | Shell |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
render | render() | Add parentheses. | Kotlin |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
status: test
title: world, | status: test
title: world | Remove comma. | YAML |
if (index = 32) {{}} | if (index == 32) {{}} | Use ==. | Java |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
values.forEach(function(count) {{ console.log(count); }}) | values.forEach((count) => {{ console.log(count); }}) | Arrow functions are cleaner. | JavaScript |
<hr></hr> | <hr> | Self-closing. | HTML |
let num: Int = 'hello' | let num: String = 'hello' | Fix type. | Swift |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
val foo = 'data' | val foo = "data" | Double quotes. | Kotlin |
function handle() {{ echo 'message'; }} | function handle() {{ echo 'message'; }} | Correct. | PHP |
SELECT * FROM users WHRE status=49; | SELECT * FROM users WHERE status=49; | Fix WHERE. | SQL |
SELECT id role FROM orders; | SELECT id, role FROM orders; | Add comma. | SQL |
my @arr = (16,40,69); | my @arr = (16,40,69); | Correct. | Perl |
disp('result') | disp('result') | Correct. | MATLAB |
if (bar = 93) | if (bar == 93) | Use ==. | C++ |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
else
print('result') | else:
print('result') | Colon after else. | Python |
'81' + 92 | 81 + 92 | Avoid string coercion. | JavaScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
values[87] | if values.indices.contains(87) {{ values[87] }} | Check index. | Swift |
{{"title":"result" "value":71}} | {{"title":"result", "value":71}} | Add comma. | JSON |
class Product {{ int item; }}; | class Product {{ public: int item; }}; | Make public. | C++ |
<table><tr><td>data<td>hello</tr></table> | <table><tr><td>data</td><td>hello</td></tr></table> | Close td. | HTML |
'test' + 21 | 'test' + 21.to_s | Convert int. | Ruby |
if foo = 51 | if foo == 51 | Use ==. | MATLAB |
if bar > 46
print('result') | if bar > 46:
print('result') | Colon missing after if. | Python |
const obj:Person = {{name:'hello'}}; | const obj:Person = {{name:'hello', age:6}}; | Add missing property. | TypeScript |
int arr[33]; arr[33]=5; | int arr[33]; if(33<33){{}} else arr[33]=5; | Bounds check. | C++ |
cin >> count; | int count;
cin >> count; | Declare variable. | C++ |
let y: number = 'data'; | let y: string = 'data'; | Fix type. | TypeScript |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
if index = 10 | if index == 10 | Use ==. | Go |
int[] list = new int[86];
list[86] = 5; | int[] list = new int[86];
if (86 < list.length) list[86] = 5; | Check bounds. | Java |
function foo(y:string){{return y;}} foo(55); | function foo(y:string){{return y;}} foo('result'); | Pass correct type. | TypeScript |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
for num in range(100)
print(num) | for num in range(100):
print(num) | Colon after for. | Python |
UPDATE items SET id='data' WHERE status=4 | UPDATE items SET id='data' WHERE status=4; | Add semicolon. | SQL |
with open('input.csv') as fp:
data = fp.read() | with open('input.csv') as fp:
data = fp.read() | Correct. | Python |
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 |
bar | bar() | Add parentheses. | Swift |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
num == '1' | num === 1 | Use strict equality. | JavaScript |
let x: i32 = "result"; | let x: &str = "result"; | Type mismatch. | Rust |
print 'info' | print('info') | print needs parentheses. | Python |
if (a = 24) | if (a == 24) | Use ==. | R |
print('test') | print('test') | Correct. | R |
WHERE id = '32' | WHERE id = 32 | Don't quote integer. | SQL |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
data[4] | if (data.indices.contains(4)) data[4] | Check index. | Kotlin |
fn bar() -> i32 {{ 72 }} | fn bar() -> i32 {{ 72 }} | Correct. | Rust |
let text = String::from("hello"); let ref=&text; text.push_str("!"); | let mut text = String::from("hello"); let ref=&text; println!("{{}}", ref); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
if count = 64: | if count == 64: | Use == for comparison. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.