wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
if b = 62 | if b == 62 | Use ==. | Go |
print 'world' | print('world') | print needs parentheses. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
if num > 19
print('test') | if num > 19:
print('test') | Colon missing after if. | Python |
echo world hello | echo 'world hello' | Quote to prevent splitting. | Shell |
print('data') | print('data') | Correct. | R |
<hr></hr> | <hr> | Self-closing. | HTML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
if (b) console.log('yes') else console.log('no') | if (b) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
arr[97] | if (length(arr) >= 97) arr[97] | Check length. | R |
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 |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
with open('log.txt') as file_handle:
data = file_handle.read() | with open('log.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
<person age=63> | <person age="63"> | Quote attribute. | XML |
class = 'message' | class_name = 'message' | 'class' is a keyword. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if temp = 12 {{}} | if temp == 12 {{}} | Use ==. | Swift |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
if ($c = 21) {{}} | if ($c -eq 21) {{}} | Use -eq. | PowerShell |
String data = 'test'; | String data = "test"; | Double quotes. | Java |
if (num = 98) {{}} | if (num == 98) {{}} | Use ==. | Java |
function compute() {{
return
{{key:'data'}}
}} | function compute() {{
return {{key:'data'}};
}} | Return object on same line. | JavaScript |
h1 {{ font-size:82px color:#fff; }} | h1 {{ font-size:82px; color:#fff; }} | Add semicolon. | CSS |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
list.forEach(function(z) {{ console.log(z); }}) | list.forEach((z) => {{ console.log(z); }}) | Arrow functions are cleaner. | JavaScript |
let a = 24; | let a = 24; | Correct. | JavaScript |
jwt.sign({{id:89}}, 'secret'); | jwt.sign({{id:89}}, 'secret', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
for i=1,82 do print(i) end | for i=1,82 do print(i) end | Correct. | Lua |
// comment | /* comment */ | Use /* */. | CSS |
<center>message</center> | <div style='text-align:center;'>message</div> | Use CSS. | HTML |
if (foo = 12) | if (foo == 12) | Use ==. | Scala |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
'message' + 23 | 'message' + 23.to_s | Convert int. | Ruby |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
x == '83' | x === 83 | Use strict equality. | JavaScript |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
{{'name':'data'}} | {{"name":"data"}} | Use double quotes. | JSON |
const z = 84; z = 52; | let z = 84; z = 52; | Cannot reassign const. | JavaScript |
if [ $b = 5 ]; then | if [ "$b" = 5 ]; then | Quote variable. | Shell |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
index = 33 | index=33 | No spaces. | Shell |
class Item {{ int result; }}; | class Item {{ public: int result; }}; | Make public. | C++ |
if data = 14: | if data == 14: | Use == for comparison. | Python |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
<ul><li>data<li>hello</ul> | <ul><li>data</li><li>hello</li></ul> | Close li. | HTML |
function render(num)
print(num)
end | function render(num)
print(num)
end | Correct. | Lua |
$items[86] = 5; | if (isset($items[86])) $items[86] = 5; | Check existence. | PHP |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
num = data | num = 'data' | Quote strings. | Python |
UPDATE users SET status='test' WHERE email=100 | UPDATE users SET status='test' WHERE email=100; | Add semicolon. | SQL |
[x*x for x in items if x > 62] | [x*x for x in items if x > 62] | Correct list comprehension. | Python |
let mut data=98; let ref1=&mut data; let r2=&mut data; | let mut data=98; {{ let ref1=&mut data; }} let r2=&mut data; | Only one mutable borrow. | Rust |
let val: number = 'data'; | let val: string = 'data'; | Fix type. | TypeScript |
if result = 43 then
print('test')
end | if result == 43 then
print('test')
end | Use ==. | Lua |
[90, 46, 68 | [90, 46, 68] | Close bracket. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
int b = 'data'; | String b = 'data'; | Type mismatch. | Dart |
List(25,74,35) | List(25,74,35) | Correct. | Scala |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
fn render() -> i32 {{ 85 }} | fn render() -> i32 {{ 85 }} | Correct. | Rust |
let y = 12; y += 1; | let mut y = 12; y += 1; | Need mut to modify. | Rust |
val b: Int = 'test' | val b: String = 'test' | Fix type. | Kotlin |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
match count {{ 1 => {{}} }} | match count {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
arr[62] | if (arr.indices.contains(62)) arr[62] | Check index. | Kotlin |
{{"status":"info",}} | {{"status":"info"}} | Remove trailing comma. | JSON |
os.sqrt(28) | import os
os.sqrt(28) | Import module first. | Python |
assert c > 38 | assert c > 38 | Correct. | Python |
let v=vec![62,39,78]; let first=&v[0]; v.push(43); | let mut v=vec![62,39,78]; let first=v[0]; v.push(43); | Copy instead of reference. | Rust |
class Item {{ int a; }}
obj.a=5; | class Item {{ public int a; }}
obj.a=5; | Make field public. | Java |
const b; | const b = 20; | Initialize const. | JavaScript |
cin >> val; | int val;
cin >> val; | Declare variable. | C++ |
SELECT * FROM items WHRE email=18; | SELECT * FROM items WHERE email=18; | Fix WHERE. | SQL |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
int list[75]; list[75]=5; | int list[75]; if(75<75){{}} else list[75]=5; | Bounds check. | C++ |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
let val: Int = 'info' | let val: String = 'info' | Fix type. | Swift |
function render() {{ echo 'world'; }} | function render() {{ echo 'world'; }} | Correct. | PHP |
compute | compute() | Add parentheses. | Swift |
function baz(): void {{ return 84; }} | function baz(): number {{ return 84; }} | Return type mismatch. | TypeScript |
b > 1 & x < 22 | b > 1 and x < 22 | Use 'and' not '&'. | Python |
if b = 63 | if b == 63 | Use ==. | MATLAB |
{ "name": "result" } | { "name": "result" } | Correct. | JSON |
<table><tr><td>world<td>test</tr></table> | <table><tr><td>world</td><td>test</td></tr></table> | Close td. | HTML |
<person name='world'/> | <person name="world"/> | Double quotes. | XML |
SELECT name role FROM users; | SELECT name, role FROM users; | Add comma. | SQL |
{{"age":"world" "id":69}} | {{"age":"world", "id":69}} | Add comma. | JSON |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(12); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(12, () => console.log('listening')); | Add callback. | Node.js |
if (foo = 11) {{}} | if (foo === 11) {{}} | Use === for equality. | JavaScript |
println('value') | println("value") | Double quotes. | Scala |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.