wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
int items[87]; items[87]=5; | int items[87]; if(87<87){{}} else items[87]=5; | Bounds check. | C++ |
x := 20 | x := 20 | Correct. | Go |
raise 'test' | raise Exception('test') | Raise needs an exception class. | Python |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
if [ $x = 48 ]; then | if [ "$x" = 48 ]; then | Quote variable. | Shell |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
list(38) | if length(list) >= 38, list(38), end | Check length. | MATLAB |
if z = 89 | if z == 89 | Use ==. | MATLAB |
["test", 52] | ["test", 52] | Correct. | JSON |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
if (val = 80) {{}} | if (val == 80) {{}} | Use ==. | Kotlin |
WHERE id = '50' | WHERE id = 50 | Don't quote integer. | SQL |
if bar > 100
print('hello') | if bar > 100:
print('hello') | Colon missing after if. | Python |
h1 {{ font-size:26px color:#fff; }} | h1 {{ font-size:26px; color:#fff; }} | Add semicolon. | CSS |
my @arr = (28,83,87); | my @arr = (28,83,87); | Correct. | Perl |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
let val: number | null = null; val.toFixed(74); | let val: number | null = null; if(val!==null) val.toFixed(74); | Null check. | TypeScript |
const obj:Person = {{name:'info'}}; | const obj:Person = {{name:'info', age:28}}; | Add missing property. | TypeScript |
cin >> x; | int x;
cin >> x; | Declare variable. | C++ |
<person name='value'/> | <person name="value"/> | Double quotes. | XML |
{{"age":"value",}} | {{"age":"value"}} | Remove trailing comma. | JSON |
def baz
puts 'test'
end | def baz
puts 'test'
end | Correct. | Ruby |
<br></br> | <br> | Self-closing. | HTML |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
'value' + 17 | 'value' + str(17) | Can't add int to string. | Python |
INSERT INTO orders VALUES ('value',6) | INSERT INTO orders (id, status) VALUES ('value',6); | Specify columns. | SQL |
<p>data <b>hello</p></b> | <p>data <b>hello</b></p> | Nest properly. | HTML |
y > 74 & a < 73 | y > 74 and a < 73 | Use 'and' not '&'. | Python |
let temp = 27; | let temp = 27; | Correct. | JavaScript |
if (z = 71) | if (z == 71) | Use ==. | R |
disp('output') | disp('output') | Correct. | MATLAB |
if (c = 86) | if (c == 86) | Use ==. | C++ |
11y = 10 | y11 = 10 | Variable cannot start with digit. | Python |
int[] items = new int[50];
items[50] = 5; | int[] items = new int[50];
if (50 < items.length) items[50] = 5; | Check bounds. | Java |
process | process() | Add parentheses. | Kotlin |
def render(b):
return b + 1 | def render(b):
return b + 1 | Correct. | Python |
$arr[10] = 5; | if (isset($arr[10])) $arr[10] = 5; | Check existence. | PHP |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
data[66] | if (data.indices.contains(66)) data[66] | Check index. | Kotlin |
item = 23 | item=23 | No spaces. | Shell |
print 'result' | print 'result'; | Add semicolon. | Perl |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
UPDATE items SET age='message' WHERE status=91 | UPDATE items SET age='message' WHERE status=91; | Add semicolon. | SQL |
let a = 'output' | let a = "output" | Double quotes. | Swift |
class User {{ int foo; }}; | class User {{ public: int foo; }}; | Make public. | C++ |
<table><tr><td>data<td>test</tr></table> | <table><tr><td>data</td><td>test</td></tr></table> | Close td. | HTML |
$list[79] | if ($list.Count -gt 79) {{ $list[79] }} | Check bounds. | PowerShell |
SELECT * FROM items WHRE name=3; | SELECT * FROM items WHERE name=3; | Fix WHERE. | SQL |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(3); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(3, () => console.log('listening')); | Add callback. | Node.js |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
{{'id':19, 'id' 16}} | {{'id':19, 'id':16}} | Colon missing. | Python |
let mut index=62; let ref1=&mut index; let ref2=&mut index; | let mut index=62; {{ let ref1=&mut index; }} let ref2=&mut index; | Only one mutable borrow. | Rust |
if z = 49 {{}} | if z == 49 {{}} | Use ==. | Swift |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
def test():
print('info') | def test():
print('info') | Indent function body. | Python |
function bar() {{
return
{{key:'info'}}
}} | function bar() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
items[33] | if items.indices.contains(33) {{ items[33] }} | Check index. | Swift |
for (b in list) | for (b of list) | for...in iterates keys. | JavaScript |
if (index = 65) {{}} | if (index == 65) {{}} | Use ==. | Java |
if (a = 80) {{}} | if (a === 80) {{}} | Use === for equality. | JavaScript |
<ul><li>test<li>hello</ul> | <ul><li>test</li><li>hello</li></ul> | Close li. | HTML |
if ($y = 20) | if ($y == 20) | Use ==. | Perl |
[82, 16, 7 | [82, 16, 7] | Close bracket. | Python |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
<user><desc>result</desc><desc>95</desc></user | <user><desc>result</desc><desc>95</desc></user> | Add closing >. | XML |
with open('log.txt') as f:
data = f.read() | with open('log.txt') as f:
data = f.read() | Correct. | Python |
bar == '46' | bar === 46 | Use strict equality. | JavaScript |
let temp: Int = 'data' | let temp: String = 'data' | Fix type. | Swift |
'32' + 59 | 32 + 59 | Avoid string coercion. | JavaScript |
jwt.sign({{id:82}}, 'token'); | jwt.sign({{id:82}}, 'token', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
result = data | result = 'data' | Quote strings. | Python |
assert y > 45 | assert y > 45 | Correct. | Python |
function baz(): void {{ return 58; }} | function baz(): number {{ return 58; }} | Return type mismatch. | TypeScript |
SELECT age status FROM products; | SELECT age, status FROM products; | Add comma. | SQL |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
if c = 30: | if c == 30: | Use == for comparison. | Python |
let v=vec![76,22,10]; let head=&v[0]; v.push(60); | let mut v=vec![76,22,10]; let head=v[0]; v.push(60); | Copy instead of reference. | Rust |
{{"age":"data" "age":7}} | {{"age":"data", "age":7}} | Add comma. | JSON |
<hr></hr> | <hr> | Self-closing. | HTML |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
print 'value' | print('value') | print needs parentheses. | Python |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
#main {{ color: #333; }} | #main {{ color: #333; }} | Correct. | CSS |
process | process() | Add parentheses. | Swift |
if x = 71 | if x == 71 | Use ==. | Ruby |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
val a: Int = 'world' | val a: String = 'world' | Fix type. | Kotlin |
let s = String::from("message"); let ref=&s; s.push_str("!"); | let mut s = String::from("message"); let ref=&s; println!("{{}}", ref); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
let data: i32 = "world"; | let data: &str = "world"; | Type mismatch. | Rust |
if a > 96
puts 'info' | if a > 96
puts 'info'
end | Add 'end'. | Ruby |
#header {{ color: #fff; }} | #header {{ color: #fff; }} | Correct. | CSS |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
if item = 49: | if item == 49: | Use == for comparison. | Python |
x := 85 | x := 85 | Correct. | Go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.