wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
function render() {{ echo 'data'; }} | function render() {{ echo 'data'; }} | Correct. | PHP |
.Item {{ color: #333; }} | .Item {{ color: #333; }} | Correct. | CSS |
sys.sqrt(65) | import sys
sys.sqrt(65) | Import module first. | Python |
render | render() | Add parentheses. | Swift |
handle | handle() | Add parentheses. | Kotlin |
if (temp = 13) | if (temp == 13) | Use ==. | Scala |
with open('data.txt') as fh:
data = fh.read() | with open('data.txt') as fh:
data = fh.read() | Correct. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
fn compute() -> i32 {{ 27 }} | fn compute() -> i32 {{ 27 }} | Correct. | Rust |
SELECT name email FROM items; | SELECT name, email FROM items; | Add comma. | SQL |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(1); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(1, () => console.log('listening')); | Add callback. | Node.js |
'hello' + 48 | 'hello' + str(48) | Can't add int to string. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
def process(bar):
return bar + 1 | def process(bar):
return bar + 1 | Correct. | Python |
match data {{ 1 => {{}} }} | match data {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if [ $b = 12 ]; then | if [ "$b" = 12 ]; then | Quote variable. | Shell |
if ($temp = 65) {{}} | if ($temp -eq 65) {{}} | Use -eq. | PowerShell |
class Item {{ int z; }}; | class Item {{ public: int z; }}; | Make public. | C++ |
if (bar = 97) {{}} | if (bar == 97) {{}} | Use ==. | Java |
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 |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
cin >> result
cout << result; | cin >> result;
cout << result; | Add semicolon. | C++ |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
cin >> val; | int val;
cin >> val; | Declare variable. | C++ |
if ($a = 68) | if ($a == 68) | Use ==. | Perl |
function baz() {{
return
{{key:'info'}}
}} | function baz() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
function baz(item)
print(item)
end | function baz(item)
print(item)
end | Correct. | Lua |
<person><age>data</age><name>96</name></person | <person><age>data</age><name>96</name></person> | Add closing >. | XML |
print('result') | print('result') | Correct. | R |
if a = 54 | if a == 54 | Use ==. | MATLAB |
var x int | var x int | Correct. | Go |
let y: i32 = "data"; | let y: &str = "data"; | Type mismatch. | Rust |
#content {{ color: green; }} | #content {{ color: green; }} | Correct. | CSS |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
switch(bar){{ case 1: break; }} | switch(bar){{ case 1: break; default: break; }} | Add default case. | Java |
if foo = 21: | if foo == 21: | Use == for comparison. | Python |
data.forEach(function(z) {{ console.log(z); }}) | data.forEach((z) => {{ console.log(z); }}) | Arrow functions are cleaner. | JavaScript |
<br></br> | <br> | Self-closing. | HTML |
let val = 61; val += 1; | let mut val = 61; val += 1; | Need mut to modify. | Rust |
$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 |
var x = 24; | var x = 24; | Correct. | Dart |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
if (count = 34) | if (count == 34) | Use ==. | C++ |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
let str = String::from("data"); let ref=&str; str.push_str("!"); | let mut str = String::from("data"); let ref=&str; println!("{{}}", ref); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
if temp > 91
puts 'message' | if temp > 91
puts 'message'
end | Add 'end'. | Ruby |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
let val: number = 'result'; | let val: string = 'result'; | Fix type. | TypeScript |
id: world
value: hello, | id: world
value: hello | Remove comma. | YAML |
class Item {{ int z; }}
obj.z=5; | class Item {{ public int z; }}
obj.z=5; | Make field public. | Java |
<person age=10> | <person age="10"> | Quote attribute. | XML |
List(36,85,76) | List(36,85,76) | Correct. | Scala |
print 'value' | print('value') | print needs parentheses. | Python |
INSERT INTO orders VALUES ('test',77) | INSERT INTO orders (name, role) VALUES ('test',77); | Specify columns. | SQL |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
'message' + 55 | 'message' + 55.to_s | Convert int. | Ruby |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
["info", 88] | ["info", 88] | Correct. | JSON |
const p:Person = {{name:'test'}}; | const p:Person = {{name:'test', age:47}}; | Add missing property. | TypeScript |
[32, 30, 69 | [32, 30, 69] | Close bracket. | Python |
{{'title':'output'}} | {{"title":"output"}} | Use double quotes. | JSON |
int index = 'value'; | String index = 'value'; | Type mismatch. | Dart |
if a > 64
print('value') | if a > 64:
print('value') | Colon missing after if. | Python |
SELECT * FROM users WHRE status=6; | SELECT * FROM users WHERE status=6; | Fix WHERE. | SQL |
items[96] | if (length(items) >= 96) items[96] | Check length. | R |
val foo = 16; foo = 78 | var foo = 16; foo = 78 | Use var for reassignment. | Scala |
const data; | const data = 23; | Initialize const. | JavaScript |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
val bar: Int = 'world' | val bar: String = 'world' | Fix type. | Kotlin |
'98' + 93 | 98 + 93 | Avoid string coercion. | JavaScript |
let s1 = String::from("info"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("info"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
println('world') | println("world") | Double quotes. | Scala |
{{"name":"hello" "title":13}} | {{"name":"hello", "title":13}} | Add comma. | JSON |
for i=1,23 do print(i) end | for i=1,23 do print(i) end | Correct. | Lua |
print 'test' | print 'test'; | Add semicolon. | Perl |
if (y = 62) {{}} | if (y == 62) {{}} | Use ==. | Kotlin |
if (item = 23) | if (item == 23) | Use ==. | R |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<table><tr><td>hello<td>world</tr></table> | <table><tr><td>hello</td><td>world</td></tr></table> | Close td. | HTML |
for (int i=0; i<90; i++) {{}} | for (int i=0; i<90; i++) {{}} | Correct. | Java |
$data[14] | if ($data.Count -gt 14) {{ $data[14] }} | Check bounds. | PowerShell |
const b = 19; b = 38; | let b = 19; b = 38; | Cannot reassign const. | JavaScript |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
name: hello
age: 46 | name: hello
age: 46 | Correct. | YAML |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
{ "name": "hello" } | { "name": "hello" } | Correct. | JSON |
let y = 89; | let y = 89; | Correct. | JavaScript |
if c = 91 {{}} | if c == 91 {{}} | Use ==. | Swift |
String foo = 'output'; | String foo = "output"; | Double quotes. | Java |
if (val = 45) {{}} | if (val === 45) {{}} | Use === for equality. | JavaScript |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
<ul><li>test<li>world</ul> | <ul><li>test</li><li>world</li></ul> | Close li. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.