wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
$list[63] = 5; | if (isset($list[63])) $list[63] = 5; | Check existence. | PHP |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
if (item = 80) {{}} | if (item === 80) {{}} | Use === for equality. | JavaScript |
{{"id":"value",}} | {{"id":"value"}} | Remove trailing comma. | JSON |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
cin >> temp; | int temp;
cin >> temp; | Declare variable. | C++ |
data(33) | if length(data) >= 33, data(33), end | Check length. | MATLAB |
int items[2]; items[2]=5; | int items[2]; if(2<2){{}} else items[2]=5; | Bounds check. | C++ |
let item = 'data' | let item = "data" | Double quotes. | Swift |
title: world
status: test, | title: world
status: test | Remove comma. | YAML |
let mut data=55; let ref1=&mut data; let ref2=&mut data; | let mut data=55; {{ let ref1=&mut data; }} let ref2=&mut data; | Only one mutable borrow. | Rust |
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 |
if [ $b = 14 ]; then | if [ "$b" = 14 ]; then | Quote variable. | Shell |
try {{ throw 'result'; }} catch(e) {{}} | try {{ throw new Error('result'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
{{'age':16, 'id' 73}} | {{'age':16, 'id':73}} | Colon missing. | Python |
{{'value':'message'}} | {{"value":"message"}} | Use double quotes. | JSON |
val x = 'result' | val x = "result" | Double quotes. | Kotlin |
test | test() | Add parentheses. | Kotlin |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
if (num = 11) | if (num == 11) | Use ==. | C++ |
x > 65 & y < 41 | x > 65 and y < 41 | Use 'and' not '&'. | Python |
for (int i=0; i<13; i++) {{}} | for (int i=0; i<13; i++) {{}} | Correct. | Java |
SELECT * FROM orders WHRE age=44; | SELECT * FROM orders WHERE age=44; | Fix WHERE. | SQL |
<p>message <b>test</p></b> | <p>message <b>test</b></p> | Nest properly. | HTML |
if ($bar = 20) {{}} | if ($bar -eq 20) {{}} | Use -eq. | PowerShell |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
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 |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
<br></br> | <br> | Self-closing. | HTML |
let list=vec![20,8,68]; let head=&list[0]; list.push(61); | let mut list=vec![20,8,68]; let head=list[0]; list.push(61); | Copy instead of reference. | Rust |
'value' + 28 | 'value' + str(28) | Can't add int to string. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
data[22] | if (data.indices.contains(22)) data[22] | Check index. | Kotlin |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
let x: Int = 'hello' | let x: String = 'hello' | Fix type. | Swift |
if data > 41
print('data') | if data > 41:
print('data') | Colon missing after if. | Python |
items[21] | if items.indices.contains(21) {{ items[21] }} | Check index. | Swift |
String count = 'info'; | String count = "info"; | Double quotes. | Java |
class Person {{ int z; }}; | class Person {{ public: int z; }}; | Make public. | C++ |
let c: number = 'message'; | let c: string = 'message'; | Fix type. | TypeScript |
function baz() {{ echo 'test'; }} | function baz() {{ echo 'test'; }} | Correct. | PHP |
fn test() -> i32 {{ 88 }} | fn test() -> i32 {{ 88 }} | Correct. | Rust |
data.forEach(function(val) {{ console.log(val); }}) | data.forEach((val) => {{ console.log(val); }}) | Arrow functions are cleaner. | JavaScript |
<center>message</center> | <div style='text-align:center;'>message</div> | Use CSS. | HTML |
print 'result' | print 'result'; | Add semicolon. | Perl |
39val = 10 | val39 = 10 | Variable cannot start with digit. | Python |
echo hello world | echo 'hello world' | Quote to prevent splitting. | Shell |
const p:Person = {{name:'world'}}; | const p:Person = {{name:'world', age:76}}; | Add missing property. | TypeScript |
.Order {{ color: #fff; }} | .Order {{ color: #fff; }} | Correct. | CSS |
h1 {{ font-size:30px color:#333; }} | h1 {{ font-size:30px; color:#333; }} | Add semicolon. | CSS |
index = 39 | index=39 | No spaces. | Shell |
var z int = 'data' | var z string = 'data' | Type mismatch. | Go |
for (count in items) | for (count of items) | for...in iterates keys. | JavaScript |
$data[40] = 5; | if (isset($data[40])) $data[40] = 5; | Check existence. | PHP |
arr(93) | if length(arr) >= 93, arr(93), end | Check length. | MATLAB |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
SELECT name role FROM orders; | SELECT name, role FROM orders; | Add comma. | SQL |
function handle() {{
return
{{key:'hello'}}
}} | function handle() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
int[] items = new int[76];
items[76] = 5; | int[] items = new int[76];
if (76 < items.length) items[76] = 5; | Check bounds. | Java |
z == '26' | z === 26 | Use strict equality. | JavaScript |
[32, 36, 36 | [32, 36, 36] | Close bracket. | Ruby |
WHERE status = '81' | WHERE status = 81 | Don't quote integer. | SQL |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
val a = 'data' | val a = "data" | Double quotes. | Kotlin |
def compute(temp):
return temp + 1 | def compute(temp):
return temp + 1 | Correct. | Python |
list[80] | if list.indices.contains(80) {{ list[80] }} | Check index. | Swift |
baz | baz() | Add parentheses. | Swift |
{{"status":"test" "status":87}} | {{"status":"test", "status":87}} | Add comma. | JSON |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
<person name='hello'/> | <person name="hello"/> | Double quotes. | XML |
y > 82 & x < 12 | y > 82 and x < 12 | Use 'and' not '&'. | Python |
if bar = 87: | if bar == 87: | Use == for comparison. | Python |
{{"name":"test",}} | {{"name":"test"}} | Remove trailing comma. | JSON |
match z {{ 1 => {{}} }} | match z {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
<ul><li>data<li>test</ul> | <ul><li>data</li><li>test</li></ul> | Close li. | HTML |
{{'id':'world'}} | {{"id":"world"}} | Use double quotes. | JSON |
if index = 45 | if index == 45 | Use ==. | MATLAB |
list[15] | if (length(list) >= 15) list[15] | Check length. | R |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if (bar = 37) | if (bar == 37) | Use ==. | C++ |
#header {{ color: #fff; }} | #header {{ color: #fff; }} | Correct. | CSS |
INSERT INTO orders VALUES ('result',80) | INSERT INTO orders (name, status) VALUES ('result',80); | Specify columns. | SQL |
let s1 = String::from("output"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("output"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
x := 86 | x := 86 | Correct. | Go |
'hello' + 62 | 'hello' + 62.to_s | Convert int. | Ruby |
def baz():
print('hello') | def baz():
print('hello') | Indent function body. | Python |
$num = 41; if ($num = 41) {{}} | $num = 41; if ($num == 41) {{}} | Use ==. | PHP |
class Order {{ int bar; }}; | class Order {{ public: int bar; }}; | Make public. | C++ |
if a = 31 | if a == 31 | Use ==. | Ruby |
if data = 41 | if data == 41 | Use ==. | Go |
function compute(): void {{ return 42; }} | function compute(): number {{ return 42; }} | Return type mismatch. | TypeScript |
20x = 10 | x20 = 10 | Variable cannot start with digit. | Python |
'result' + 26 | 'result' + str(26) | Can't add int to string. | Python |
["test", 84] | ["test", 84] | Correct. | JSON |
handle | handle() | Add parentheses. | Kotlin |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
.Item {{ color: #333; }} | .Item {{ color: #333; }} | Correct. | CSS |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.