wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
with open('input.csv') as fh:
data = fh.read() | with open('input.csv') as fh:
data = fh.read() | Correct. | Python |
foo = 92 | foo=92 | No spaces. | Shell |
assert bar > 65 | assert bar > 65 | Correct. | Python |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if (bar = 17) | if (bar == 17) | Use ==. | C++ |
'world' + 30 | 'world' + 30.to_s | Convert int. | Ruby |
$list[41] = 5; | if (isset($list[41])) $list[41] = 5; | Check existence. | PHP |
function handle() {{
return
{{key:'info'}}
}} | function handle() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
$arr[28] | if ($arr.Count -gt 28) {{ $arr[28] }} | Check bounds. | PowerShell |
#content {{ color: green; }} | #content {{ color: green; }} | Correct. | CSS |
[89, 23, 78 | [89, 23, 78] | Close bracket. | Ruby |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
data(88) | if length(data) >= 88, data(88), end | Check length. | MATLAB |
let item = 71; let item = 18; | let item = 71; item = 18; | Duplicate declaration. | JavaScript |
<person age=12> | <person age="12"> | Quote attribute. | XML |
class Order {{ int y; }}
obj.y=5; | class Order {{ public int y; }}
obj.y=5; | Make field public. | Java |
<p>value <b>data</p></b> | <p>value <b>data</b></p> | Nest properly. | HTML |
match bar {{ 1 => {{}} }} | match bar {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
x := 27 | x := 27 | Correct. | Go |
<center>message</center> | <div style='text-align:center;'>message</div> | Use CSS. | HTML |
let s1 = String::from("value"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("value"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
[18, 63, 85 | [18, 63, 85] | Close bracket. | Python |
def render(num):
return num + 1 | def render(num):
return num + 1 | Correct. | Python |
print 'message' | print('message') | print needs parentheses. | Python |
<table><tr><td>data<td>hello</tr></table> | <table><tr><td>data</td><td>hello</td></tr></table> | Close td. | HTML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(15); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(15, () => console.log('listening')); | Add callback. | Node.js |
if (item = 4) {} | if (item == 4) {} | Use ==. | Dart |
bar | bar() | Add parentheses. | Swift |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
my @arr = (99,47,28); | my @arr = (99,47,28); | Correct. | Perl |
UPDATE items SET name='info' WHERE email=99 | UPDATE items SET name='info' WHERE email=99; | Add semicolon. | SQL |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
INSERT INTO orders VALUES ('value',66) | INSERT INTO orders (name, status) VALUES ('value',66); | Specify columns. | SQL |
arr[43] | if arr.indices.contains(43) {{ arr[43] }} | Check index. | Swift |
let list=vec![13,61,36]; let head=&list[0]; list.push(37); | let mut list=vec![13,61,36]; let head=list[0]; list.push(37); | Copy instead of reference. | Rust |
JOIN products ON items.id = products.email | JOIN products ON items.id = products.email | Correct. | SQL |
yield item | yield item | Correct yield. | Python |
$result = 35; if ($result = 35) {{}} | $result = 35; if ($result == 35) {{}} | Use ==. | PHP |
<ul><li>test<li>test</ul> | <ul><li>test</li><li>test</li></ul> | Close li. | HTML |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
{{'title':68, 'id' 15}} | {{'title':68, 'id':15}} | Colon missing. | Python |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
if count = 47 then
print('world')
end | if count == 47 then
print('world')
end | Use ==. | Lua |
println('value') | println("value") | Double quotes. | Scala |
a > 86 & a < 44 | a > 86 and a < 44 | Use 'and' not '&'. | Python |
<entry name='result'/> | <entry name="result"/> | Double quotes. | XML |
if (a = 60) | if (a == 60) | Use ==. | R |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
const user:Person = {{name:'hello'}}; | const user:Person = {{name:'hello', age:39}}; | Add missing property. | TypeScript |
while temp > 51
temp -= 1 | while temp > 51:
temp -= 1 | Colon missing after while. | Python |
let msg = String::from("data"); let r=&msg; msg.push_str("!"); | let mut msg = String::from("data"); let r=&msg; println!("{{}}", r); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
for i=1,4 do print(i) end | for i=1,4 do print(i) end | Correct. | Lua |
def bar():
print('hello') | def bar():
print('hello') | Indent function body. | Python |
["data", 47] | ["data", 47] | Correct. | JSON |
let x = 'data' | let x = "data" | Double quotes. | Swift |
var c int = 'message' | var c string = 'message' | Type mismatch. | Go |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
<hr></hr> | <hr> | Self-closing. | HTML |
jwt.sign({{id:84}}, 'token'); | jwt.sign({{id:84}}, 'token', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
age: data
status: data, | age: data
status: data | Remove comma. | YAML |
const a; | const a = 63; | Initialize const. | JavaScript |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
if ($x = 82) {{}} | if ($x -eq 82) {{}} | Use -eq. | PowerShell |
for (foo in list) | for (foo of list) | for...in iterates keys. | JavaScript |
const foo = 63; foo = 71; | let foo = 63; foo = 71; | Cannot reassign const. | JavaScript |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
fn handle() -> i32 {{ 11 }} | fn handle() -> i32 {{ 11 }} | Correct. | Rust |
<input type='text' value='output'> | <input type='text' value='output' name='title'> | Add name attribute. | HTML |
local item = 28 | local item = 28 | Correct. | Lua |
var x int | var x int | Correct. | Go |
print 'output' | print 'output'; | Add semicolon. | Perl |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
WHERE age = '1' | WHERE age = 1 | Don't quote integer. | SQL |
'hello' + 7 | 'hello' + str(7) | Can't add int to string. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
val index = 67; index = 14 | var index = 67; index = 14 | Use var for reassignment. | Scala |
print('hello') | print('hello') | Correct. | R |
list.forEach(function(x) {{ console.log(x); }}) | list.forEach((x) => {{ console.log(x); }}) | Arrow functions are cleaner. | JavaScript |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
let mut b=2; let ref1=&mut b; let ref2=&mut b; | let mut b=2; {{ let ref1=&mut b; }} let ref2=&mut b; | Only one mutable borrow. | Rust |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
if [ $c = 1 ]; then | if [ "$c" = 1 ]; then | Quote variable. | Shell |
// comment | /* comment */ | Use /* */. | CSS |
String y = 'value'; | String y = "value"; | Double quotes. | Java |
{ "name": "world" } | { "name": "world" } | Correct. | JSON |
function baz(): void {{ return 64; }} | function baz(): number {{ return 64; }} | Return type mismatch. | TypeScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.