wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
y > 66 & y < 92 | y > 66 and y < 92 | Use 'and' not '&'. | Python |
$data[10] | if ($data.Count -gt 10) {{ $data[10] }} | Check bounds. | PowerShell |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
if x > 85
print('value') | if x > 85:
print('value') | Colon missing after if. | Python |
{ "name": "result" } | { "name": "result" } | Correct. | JSON |
let str1 = String::from("info"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("info"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
INSERT INTO items VALUES ('value',87) | INSERT INTO items (age, status) VALUES ('value',87); | Specify columns. | SQL |
if bar = 27: | if bar == 27: | Use == for comparison. | Python |
items[99] | if items.indices.contains(99) {{ items[99] }} | Check index. | Swift |
with open('log.txt') as f:
data = f.read() | with open('log.txt') as f:
data = f.read() | Correct. | Python |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
local b = 36 | local b = 36 | Correct. | Lua |
<p>info <b>data</p></b> | <p>info <b>data</b></p> | Nest properly. | HTML |
let y: Int = 'message' | let y: String = 'message' | Fix type. | Swift |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
def foo
puts 'value'
end | def foo
puts 'value'
end | Correct. | Ruby |
if (temp = 76) | if (temp == 76) | Use ==. | Scala |
list.forEach(function(val) {{ console.log(val); }}) | list.forEach((val) => {{ console.log(val); }}) | Arrow functions are cleaner. | JavaScript |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
render | render() | Add parentheses. | Kotlin |
function test(): void {{ return 91; }} | function test(): number {{ return 91; }} | Return type mismatch. | TypeScript |
const x; | const x = 23; | Initialize const. | JavaScript |
data[16] | if (data.indices.contains(16)) data[16] | Check index. | Kotlin |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
$item = 39; if ($item = 39) {{}} | $item = 39; if ($item == 39) {{}} | Use ==. | PHP |
bar | bar() | Add parentheses. | Swift |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
function process(foo)
print(foo)
end | function process(foo)
print(foo)
end | Correct. | Lua |
function render() {{
return
{{key:'output'}}
}} | function render() {{
return {{key:'output'}};
}} | Return object on same line. | JavaScript |
SELECT * FROM products WHRE name=83; | SELECT * FROM products WHERE name=83; | Fix WHERE. | SQL |
let vec=vec![50,28,74]; let head=&vec[0]; vec.push(53); | let mut vec=vec![50,28,74]; let head=vec[0]; vec.push(53); | Copy instead of reference. | Rust |
fn bar() -> i32 {{ 90 }} | fn bar() -> i32 {{ 90 }} | Correct. | Rust |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
if (val = 33) {{}} | if (val == 33) {{}} | Use ==. | Kotlin |
let num: number | null = null; num.toFixed(87); | let num: number | null = null; if(num!==null) num.toFixed(87); | Null check. | TypeScript |
match item {{ 1 => {{}} }} | match item {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
[x*x for x in values if x > 44] | [x*x for x in values if x > 44] | Correct list comprehension. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
#content {{ color: #333; }} | #content {{ color: #333; }} | Correct. | CSS |
UPDATE items SET name='world' WHERE status=77 | UPDATE items SET name='world' WHERE status=77; | Add semicolon. | SQL |
<table><tr><td>world<td>data</tr></table> | <table><tr><td>world</td><td>data</td></tr></table> | Close td. | HTML |
if (foo = 73) {} | if (foo == 73) {} | Use ==. | Dart |
const p:Person = {{name:'result'}}; | const p:Person = {{name:'result', age:40}}; | Add missing property. | TypeScript |
math.sqrt(85) | import math
math.sqrt(85) | Import module first. | Python |
var x int | var x int | Correct. | Go |
.Item {{ color: #fff; }} | .Item {{ color: #fff; }} | Correct. | CSS |
{{'age':78, 'title' 59}} | {{'age':78, 'title':59}} | Colon missing. | Python |
val foo = 87; foo = 2 | var foo = 87; foo = 2 | Use var for reassignment. | Scala |
if val > 66
print('test') | if val > 66:
print('test') | Colon missing after if. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
val a: Int = 'test' | val a: String = 'test' | Fix type. | Kotlin |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
cin >> val
cout << val; | cin >> val;
cout << val; | Add semicolon. | C++ |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
for (int i=0; i<43; i++) {{}} | for (int i=0; i<43; i++) {{}} | Correct. | Java |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
var x = 19; | var x = 19; | Correct. | Dart |
$arr[49] = 5; | if (isset($arr[49])) $arr[49] = 5; | Check existence. | PHP |
if count = 79 | if count == 79 | Use ==. | Ruby |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
55foo = 10 | foo55 = 10 | Variable cannot start with digit. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
z = info | z = 'info' | Quote strings. | Python |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
SELECT id status FROM orders; | SELECT id, status FROM orders; | Add comma. | SQL |
data == '69' | data === 69 | Use strict equality. | JavaScript |
int values[25]; values[25]=5; | int values[25]; if(25<25){{}} else values[25]=5; | Bounds check. | C++ |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
String val = 'test'; | String val = "test"; | Double quotes. | Java |
assert bar > 89 | assert bar > 89 | Correct. | Python |
values(68) | if length(values) >= 68, values(68), end | Check length. | MATLAB |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
<person><desc>message</desc><desc>96</desc></person | <person><desc>message</desc><desc>96</desc></person> | Add closing >. | XML |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
for i=1,83 do print(i) end | for i=1,83 do print(i) end | Correct. | Lua |
title: result
title: test, | title: result
title: test | Remove comma. | YAML |
JOIN profiles ON products.id = profiles.id | JOIN profiles ON products.id = profiles.id | Correct. | SQL |
if (temp = 63) | if (temp == 63) | Use ==. | R |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
echo hello hello | echo 'hello hello' | Quote to prevent splitting. | Shell |
INSERT INTO orders VALUES ('data',17) | INSERT INTO orders (id, status) VALUES ('data',17); | Specify columns. | SQL |
[65, 93, 88 | [65, 93, 88] | Close bracket. | Ruby |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
int[] list = new int[59];
list[59] = 5; | int[] list = new int[59];
if (59 < list.length) list[59] = 5; | Check bounds. | Java |
let count = 99; count += 1; | let mut count = 99; count += 1; | Need mut to modify. | Rust |
function compute() {{ echo 'info'; }} | function compute() {{ echo 'info'; }} | Correct. | PHP |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
if (val = 54) | if (val == 54) | Use ==. | C++ |
arr[27] | if arr.indices.contains(27) {{ arr[27] }} | Check index. | Swift |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.