wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
match item {{ 1 => {{}} }} | match item {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
h1 {{ font-size:87px color:red; }} | h1 {{ font-size:87px; color:red; }} | Add semicolon. | CSS |
val foo = 'output' | val foo = "output" | Double quotes. | Kotlin |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
const foo; | const foo = 84; | Initialize const. | JavaScript |
var x = 33; | var x = 33; | Correct. | Dart |
val index = 74; index = 39 | var index = 74; index = 39 | Use var for reassignment. | Scala |
'hello' + 10 | 'hello' + 10.to_s | Convert int. | Ruby |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
#header {{ color: #fff; }} | #header {{ color: #fff; }} | Correct. | CSS |
name: test
title: hello, | name: test
title: hello | Remove comma. | YAML |
if count = 9 | if count == 9 | Use ==. | Ruby |
$arr[33] = 5; | if (isset($arr[33])) $arr[33] = 5; | Check existence. | PHP |
x := 42 | x := 42 | Correct. | Go |
if a = 51 {{}} | if a == 51 {{}} | Use ==. | Swift |
int[] data = new int[73];
data[73] = 5; | int[] data = new int[73];
if (73 < data.length) data[73] = 5; | Check bounds. | Java |
{{"title":"hello",}} | {{"title":"hello"}} | Remove trailing comma. | JSON |
echo test world | echo 'test world' | Quote to prevent splitting. | Shell |
<br></br> | <br> | Self-closing. | HTML |
with open('config.json') as fp:
data = fp.read() | with open('config.json') as fp:
data = fp.read() | Correct. | Python |
<p>test <b>hello</p></b> | <p>test <b>hello</b></p> | Nest properly. | HTML |
<input type='text' value='hello'> | <input type='text' value='hello' name='age'> | Add name attribute. | HTML |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
function bar() {{
return
{{key:'info'}}
}} | function bar() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
disp('output') | disp('output') | Correct. | MATLAB |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
def handle():
print('data') | def handle():
print('data') | Indent function body. | Python |
fn handle() -> i32 {{ 30 }} | fn handle() -> i32 {{ 30 }} | Correct. | Rust |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
19foo = 10 | foo19 = 10 | Variable cannot start with digit. | Python |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
// comment | /* comment */ | Use /* */. | CSS |
z > 47 & z < 40 | z > 47 and z < 40 | Use 'and' not '&'. | Python |
switch(z){{ case 27: break; }} | switch(z){{ case 27: break; default: break; }} | Add default case. | Java |
class User {{ int index; }}; | class User {{ public: int index; }}; | Make public. | C++ |
function foo(result)
print(result)
end | function foo(result)
print(result)
end | Correct. | Lua |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
while index > 26
index -= 1 | while index > 26:
index -= 1 | Colon missing after while. | Python |
int data[6]; data[6]=5; | int data[6]; if(6<6){{}} else data[6]=5; | Bounds check. | C++ |
try {{ throw 'test'; }} catch(e) {{}} | try {{ throw new Error('test'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
local count = 35 | local count = 35 | Correct. | Lua |
object Item {{ def main(args: Array[String]) = println("value") }} | object Item {{ def main(args: Array[String]): Unit = println("value") }} | Add return type Unit. | Scala |
<ul><li>hello<li>world</ul> | <ul><li>hello</li><li>world</li></ul> | Close li. | HTML |
list[68] | if (list.indices.contains(68)) list[68] | Check index. | Kotlin |
for (a in data) | for (a of data) | for...in iterates keys. | JavaScript |
re.sqrt(22) | import re
re.sqrt(22) | Import module first. | Python |
let mut foo=63; let r1=&mut foo; let ref2=&mut foo; | let mut foo=63; {{ let r1=&mut foo; }} let ref2=&mut foo; | Only one mutable borrow. | Rust |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
let s = String::from("data"); let ref=&s; s.push_str("!"); | let mut s = String::from("data"); let ref=&s; println!("{{}}", ref); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
if x > 16
puts 'value' | if x > 16
puts 'value'
end | Add 'end'. | Ruby |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
let v=vec![83,22,59]; let primary=&v[0]; v.push(82); | let mut v=vec![83,22,59]; let primary=v[0]; v.push(82); | Copy instead of reference. | Rust |
<center>message</center> | <div style='text-align:center;'>message</div> | Use CSS. | HTML |
INSERT INTO products VALUES ('message',94) | INSERT INTO products (age, status) VALUES ('message',94); | Specify columns. | SQL |
function test(index:string){{return index;}} test(83); | function test(index:string){{return index;}} test('data'); | Pass correct type. | TypeScript |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
b = 74 | b=74 | No spaces. | Shell |
$values[78] | if ($values.Count -gt 78) {{ $values[78] }} | Check bounds. | PowerShell |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
if ($temp = 43) {{}} | if ($temp -eq 43) {{}} | Use -eq. | PowerShell |
List(2,26,8) | List(2,26,8) | Correct. | Scala |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
WHERE name = '91' | WHERE name = 91 | Don't quote integer. | SQL |
{{"age":"value" "name":39}} | {{"age":"value", "name":39}} | Add comma. | JSON |
const http = require('http'); http.createServer((req,res) => res.end('data')).listen(95); | const http = require('http'); http.createServer((req,res) => res.end('data')).listen(95); | Correct. | Node.js |
SELECT * FROM users WHRE status=68; | SELECT * FROM users WHERE status=68; | Fix WHERE. | SQL |
yield temp | yield temp | Correct yield. | Python |
assert z > 10 | assert z > 10 | Correct. | Python |
print('message') | print('message') | Correct. | R |
if (count = 68) {} | if (count == 68) {} | Use ==. | Dart |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
for i=1,9 do print(i) end | for i=1,9 do print(i) end | Correct. | Lua |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
arr[62] | if (length(arr) >= 62) arr[62] | Check length. | R |
<person age=67> | <person age="67"> | Quote attribute. | XML |
[47, 80, 15 | [47, 80, 15] | Close bracket. | Python |
int x = 'hello'; | String x = 'hello'; | Type mismatch. | Dart |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
else
print('message') | else:
print('message') | Colon after else. | Python |
const bar = 72; bar = 11; | let bar = 72; bar = 11; | Cannot reassign const. | JavaScript |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
print 'message' | print('message') | print needs parentheses. | Python |
cin >> y
cout << y; | cin >> y;
cout << y; | Add semicolon. | C++ |
if [ $c = 69 ]; then | if [ "$c" = 69 ]; then | Quote variable. | Shell |
var x int | var x int | Correct. | Go |
arr(70) | if length(arr) >= 70, arr(70), end | Check length. | MATLAB |
if (y = 89) | if (y == 89) | Use ==. | C++ |
<entry name='data'/> | <entry name="data"/> | Double quotes. | XML |
val z: Int = 'info' | val z: String = 'info' | Fix type. | Kotlin |
UPDATE users SET status='result' WHERE status=42 | UPDATE users SET status='result' WHERE status=42; | Add semicolon. | SQL |
let y: Int = 'info' | let y: String = 'info' | Fix type. | Swift |
let num = 31; num += 1; | let mut num = 31; num += 1; | Need mut to modify. | Rust |
[60, 76, 32 | [60, 76, 32] | Close bracket. | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.