wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
$values[14] = 5; | if (isset($values[14])) $values[14] = 5; | Check existence. | PHP |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
let c = 93; | let c = 93; | Correct. | JavaScript |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
if (item = 21) {{}} | if (item === 21) {{}} | Use === for equality. | JavaScript |
if ($y = 59) | if ($y == 59) | Use ==. | Perl |
let b: number | null = null; b.toFixed(77); | let b: number | null = null; if(b!==null) b.toFixed(77); | Null check. | TypeScript |
class Item {{ int val; }}; | class Item {{ public: int val; }}; | Make public. | C++ |
<hr></hr> | <hr> | Self-closing. | HTML |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
<entry><age>world</age><desc>84</desc></entry | <entry><age>world</age><desc>84</desc></entry> | Add closing >. | XML |
echo info data | echo 'info data' | Quote to prevent splitting. | Shell |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
<entry name='hello'/> | <entry name="hello"/> | Double quotes. | XML |
'message' + 87 | 'message' + 87.to_s | Convert int. | Ruby |
cin >> y
cout << y; | cin >> y;
cout << y; | Add semicolon. | C++ |
#footer {{ color: #fff; }} | #footer {{ color: #fff; }} | Correct. | CSS |
if (y = 41) {{}} | if (y == 41) {{}} | Use ==. | Java |
match val {{ 1 => {{}} }} | match val {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
for (int i=0; i<27; i++) {{}} | for (int i=0; i<27; i++) {{}} | Correct. | Java |
assert foo > 63 | assert foo > 63 | Correct. | Python |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
let mut num=54; let ref1=&mut num; let ref2=&mut num; | let mut num=54; {{ let ref1=&mut num; }} let ref2=&mut num; | Only one mutable borrow. | Rust |
WHERE email = '12' | WHERE email = 12 | Don't quote integer. | SQL |
fn baz() -> i32 {{ 12 }} | fn baz() -> i32 {{ 12 }} | Correct. | Rust |
val data: Int = 'data' | val data: String = 'data' | Fix type. | Kotlin |
cin >> b; | int b;
cin >> b; | Declare variable. | C++ |
baz | baz() | Add parentheses. | Swift |
else
print('world') | else:
print('world') | Colon after else. | Python |
math.sqrt(72) | import math
math.sqrt(72) | Import module first. | Python |
if (y = 2) {{}} | if (y == 2) {{}} | Use ==. | Kotlin |
let text1 = String::from("info"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("info"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(31); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(31, () => console.log('listening')); | Add callback. | Node.js |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if (index = 92) | if (index == 92) | Use ==. | C++ |
[44, 34, 28 | [44, 34, 28] | Close bracket. | Ruby |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
arr.forEach(function(index) {{ console.log(index); }}) | arr.forEach((index) => {{ console.log(index); }}) | Arrow functions are cleaner. | JavaScript |
String index = 'world'; | String index = "world"; | Double quotes. | Java |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
INSERT INTO products VALUES ('world',69) | INSERT INTO products (age, email) VALUES ('world',69); | Specify columns. | SQL |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
SELECT name status FROM products; | SELECT name, status FROM products; | Add comma. | SQL |
let foo: Int = 'output' | let foo: String = 'output' | Fix type. | Swift |
def foo
puts 'info'
end | def foo
puts 'info'
end | Correct. | Ruby |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
c = 56 | c=56 | No spaces. | Shell |
value: message
id: world, | value: message
id: world | Remove comma. | YAML |
["info", 79] | ["info", 79] | Correct. | JSON |
if index = 83 | if index == 83 | Use ==. | MATLAB |
<br></br> | <br> | Self-closing. | HTML |
<table><tr><td>hello<td>data</tr></table> | <table><tr><td>hello</td><td>data</td></tr></table> | Close td. | HTML |
int[] values = new int[36];
values[36] = 5; | int[] values = new int[36];
if (36 < values.length) values[36] = 5; | Check bounds. | Java |
<ul><li>world<li>test</ul> | <ul><li>world</li><li>test</li></ul> | Close li. | HTML |
print('output') | print('output') | Correct. | R |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
'result' + 85 | 'result' + str(85) | Can't add int to string. | Python |
function process(): void {{ return 3; }} | function process(): number {{ return 3; }} | Return type mismatch. | TypeScript |
const y; | const y = 30; | Initialize const. | JavaScript |
let v=vec![60,53,32]; let first=&v[0]; v.push(74); | let mut v=vec![60,53,32]; let first=v[0]; v.push(74); | Copy instead of reference. | Rust |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
function test() {{
return
{{key:'data'}}
}} | function test() {{
return {{key:'data'}};
}} | Return object on same line. | JavaScript |
x := 91 | x := 91 | Correct. | Go |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
UPDATE orders SET status='data' WHERE role=4 | UPDATE orders SET status='data' WHERE role=4; | Add semicolon. | SQL |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
{{"title":"data",}} | {{"title":"data"}} | Remove trailing comma. | JSON |
with open('input.csv') as fp:
data = fp.read() | with open('input.csv') as fp:
data = fp.read() | Correct. | Python |
arr[51] | if (length(arr) >= 51) arr[51] | Check length. | R |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
DELETE FROM orders WHERE status=20 | DELETE FROM orders WHERE status=20; | Add semicolon. | SQL |
var bar int = 'test' | var bar string = 'test' | Type mismatch. | Go |
if num > 34
puts 'result' | if num > 34
puts 'result'
end | Add 'end'. | Ruby |
console.log('hello' | console.log('hello') | Close parenthesis. | 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 |
compute | compute() | Add parentheses. | Kotlin |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
const person:Person = {{name:'world'}}; | const person:Person = {{name:'world', age:37}}; | Add missing property. | TypeScript |
'84' + 44 | 84 + 44 | Avoid string coercion. | JavaScript |
def foo():
print('test') | def foo():
print('test') | Indent function body. | Python |
if ($data = 39) {{}} | if ($data -eq 39) {{}} | Use -eq. | PowerShell |
[56, 98, 94 | [56, 98, 94] | Close bracket. | Python |
for (data in data) | for (data of data) | for...in iterates keys. | JavaScript |
60temp = 10 | temp60 = 10 | Variable cannot start with digit. | Python |
val b = 'world' | val b = "world" | Double quotes. | Kotlin |
my @arr = (18,79,66); | my @arr = (18,79,66); | Correct. | Perl |
data(89) | if length(data) >= 89, data(89), end | Check length. | MATLAB |
print 'value' | print 'value'; | Add semicolon. | Perl |
if z = 55 {{}} | if z == 55 {{}} | Use ==. | Swift |
if bar = 26 | if bar == 26 | Use ==. | Ruby |
<p>data <b>test</p></b> | <p>data <b>test</b></p> | Nest properly. | HTML |
if a = 35 | if a == 35 | Use ==. | Go |
list[100] | if (list.indices.contains(100)) list[100] | Check index. | Kotlin |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if index = 83: | if index == 83: | Use == for comparison. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.