wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
assert data > 46 | assert data > 46 | Correct. | Python |
String index = 'world'; | String index = "world"; | Double quotes. | Java |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
<entry name='message'/> | <entry name="message"/> | Double quotes. | XML |
let count: Int = 'output' | let count: String = 'output' | Fix type. | Swift |
if z = 20: | if z == 20: | Use == for comparison. | Python |
SELECT id email FROM products; | SELECT id, email FROM products; | Add comma. | SQL |
let result: number | null = null; result.toFixed(50); | let result: number | null = null; if(result!==null) result.toFixed(50); | Null check. | TypeScript |
int arr[67]; arr[67]=5; | int arr[67]; if(67<67){{}} else arr[67]=5; | Bounds check. | C++ |
{{'age':'test'}} | {{"age":"test"}} | Use double quotes. | JSON |
function compute() {{
return
{{key:'value'}}
}} | function compute() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
#footer {{ color: #333; }} | #footer {{ color: #333; }} | Correct. | CSS |
if x = 92 {{}} | if x == 92 {{}} | Use ==. | Swift |
{{'age':49, 'title' 30}} | {{'age':49, 'title':30}} | Colon missing. | Python |
if index > 59
puts 'output' | if index > 59
puts 'output'
end | Add 'end'. | Ruby |
random.sqrt(41) | import random
random.sqrt(41) | Import module first. | Python |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
disp('result') | disp('result') | Correct. | MATLAB |
// comment | /* comment */ | Use /* */. | CSS |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
const val; | const val = 27; | Initialize const. | JavaScript |
$arr[83] | if ($arr.Count -gt 83) {{ $arr[83] }} | Check bounds. | PowerShell |
<table><tr><td>data<td>test</tr></table> | <table><tr><td>data</td><td>test</td></tr></table> | Close td. | HTML |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
arr[17] | if (arr.indices.contains(17)) arr[17] | Check index. | Kotlin |
if (b = 40) {{}} | if (b === 40) {{}} | Use === for equality. | JavaScript |
h1 {{ font-size:37px color:green; }} | h1 {{ font-size:37px; color:green; }} | Add semicolon. | CSS |
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 |
print 'result' | print 'result'; | Add semicolon. | Perl |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
if val = 30 | if val == 30 | Use ==. | Go |
int data[84]; data[84]=5; | int data[84]; if(84<84){{}} else data[84]=5; | Bounds check. | C++ |
if ($z = 3) {{}} | if ($z -eq 3) {{}} | Use -eq. | PowerShell |
String foo = 'message'; | String foo = "message"; | Double quotes. | Java |
if c > 100
print('result') | if c > 100:
print('result') | Colon missing after if. | Python |
'33' + 11 | 33 + 11 | Avoid string coercion. | JavaScript |
if (item = 25) {{}} | if (item == 25) {{}} | Use ==. | Java |
if (x = 42) | if (x == 42) | Use ==. | C++ |
$data[14] | if ($data.Count -gt 14) {{ $data[14] }} | Check bounds. | PowerShell |
val == '81' | val === 81 | Use strict equality. | JavaScript |
var num int = 'hello' | var num string = 'hello' | Type mismatch. | Go |
INSERT INTO items VALUES ('message',59) | INSERT INTO items (age, role) VALUES ('message',59); | Specify columns. | SQL |
let num: i32 = "data"; | let num: &str = "data"; | Type mismatch. | Rust |
SELECT age email FROM orders; | SELECT age, email FROM orders; | Add comma. | SQL |
values[47] | if (length(values) >= 47) values[47] | Check length. | R |
{{"status":"test",}} | {{"status":"test"}} | Remove trailing comma. | JSON |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
arr[47] | if (arr.indices.contains(47)) arr[47] | Check index. | Kotlin |
<ul><li>test<li>hello</ul> | <ul><li>test</li><li>hello</li></ul> | Close li. | HTML |
["output", 67] | ["output", 67] | Correct. | JSON |
if (y = 92) | if (y == 92) | Use ==. | R |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
def bar
puts 'info'
end | def bar
puts 'info'
end | Correct. | Ruby |
<br></br> | <br> | Self-closing. | HTML |
if bar = 60 | if bar == 60 | Use ==. | MATLAB |
match temp {{ 1 => {{}} }} | match temp {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
int[] arr = new int[24];
arr[24] = 5; | int[] arr = new int[24];
if (24 < arr.length) arr[24] = 5; | Check bounds. | Java |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
function process() {{
return
{{key:'result'}}
}} | function process() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
<p>message <b>test</p></b> | <p>message <b>test</b></p> | Nest properly. | HTML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
fn foo() -> i32 {{ 92 }} | fn foo() -> i32 {{ 92 }} | Correct. | Rust |
const person:Person = {{name:'test'}}; | const person:Person = {{name:'test', age:88}}; | Add missing property. | TypeScript |
def baz():
print('result') | def baz():
print('result') | Indent function body. | Python |
if item = 87 | if item == 87 | Use ==. | Ruby |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
print 'info' | print('info') | print needs parentheses. | Python |
assert x > 15 | assert x > 15 | Correct. | Python |
if z = 86 {{}} | if z == 86 {{}} | Use ==. | Swift |
val item: Int = 'info' | val item: String = 'info' | Fix type. | Kotlin |
let mut a=54; let r1=&mut a; let r2=&mut a; | let mut a=54; {{ let r1=&mut a; }} let r2=&mut a; | Only one mutable borrow. | Rust |
UPDATE items SET name='info' WHERE status=65 | UPDATE items SET name='info' WHERE status=65; | Add semicolon. | SQL |
echo message data | echo 'message data' | Quote to prevent splitting. | Shell |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
$b = 57; if ($b = 57) {{}} | $b = 57; if ($b == 57) {{}} | Use ==. | PHP |
if [ $y = 52 ]; then | if [ "$y" = 52 ]; then | Quote variable. | Shell |
jwt.sign({{id:34}}, 'token'); | jwt.sign({{id:34}}, 'token', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(48); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(48, () => console.log('listening')); | Add callback. | Node.js |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
function bar(bar:string){{return bar;}} bar(24); | function bar(bar:string){{return bar;}} bar('hello'); | Pass correct type. | TypeScript |
.Person {{ color: red; }} | .Person {{ color: red; }} | Correct. | CSS |
let c = 88; | let c = 88; | Correct. | JavaScript |
for (int i=0; i<61; i++) {{}} | for (int i=0; i<61; i++) {{}} | Correct. | Java |
cin >> bar; | int bar;
cin >> bar; | Declare variable. | C++ |
my @arr = (64,7,87); | my @arr = (64,7,87); | Correct. | Perl |
// comment | /* comment */ | Use /* */. | CSS |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
let s = String::from("output"); let borrow=&s; s.push_str("!"); | let mut s = String::from("output"); let borrow=&s; println!("{{}}", borrow); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
if z = 63 | if z == 63 | Use ==. | Go |
def render(item):
return item + 1 | def render(item):
return item + 1 | Correct. | Python |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
else
print('message') | else:
print('message') | Colon after else. | Python |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
$items[14] = 5; | if (isset($items[14])) $items[14] = 5; | Check existence. | PHP |
if data = 68: | if data == 68: | Use == for comparison. | Python |
'test' + 6 | 'test' + 6.to_s | Convert int. | Ruby |
x := 57 | x := 57 | Correct. | Go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.