wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
if (z = 93) {{}} | if (z == 93) {{}} | Use ==. | Kotlin |
int[] items = new int[88];
items[88] = 5; | int[] items = new int[88];
if (88 < items.length) items[88] = 5; | Check bounds. | Java |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
if ($index = 44) | if ($index == 44) | Use ==. | Perl |
else
print('result') | else:
print('result') | Colon after else. | Python |
if [ $b = 39 ]; then | if [ "$b" = 39 ]; then | Quote variable. | Shell |
match foo {{ 1 => {{}} }} | match foo {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
name: message
age: 1 | name: message
age: 1 | Correct. | YAML |
int foo = 'result'; | String foo = 'result'; | Type mismatch. | Dart |
jwt.sign({{id:14}}, 'secret'); | jwt.sign({{id:14}}, 'secret', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
if (y = 44) {{}} | if (y == 44) {{}} | Use ==. | Java |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
let a: number = 'message'; | let a: string = 'message'; | Fix type. | TypeScript |
for (num in list) | for (num of list) | for...in iterates keys. | JavaScript |
values.forEach(function(x) {{ console.log(x); }}) | values.forEach((x) => {{ console.log(x); }}) | Arrow functions are cleaner. | JavaScript |
#main {{ color: blue; }} | #main {{ color: blue; }} | Correct. | CSS |
if (a = 46) | if (a == 46) | Use ==. | C++ |
<table><tr><td>data<td>hello</tr></table> | <table><tr><td>data</td><td>hello</td></tr></table> | Close td. | HTML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
if foo = 95: | if foo == 95: | Use == for comparison. | Python |
[100, 26, 81 | [100, 26, 81] | Close bracket. | Ruby |
INSERT INTO orders VALUES ('world',99) | INSERT INTO orders (age, role) VALUES ('world',99); | Specify columns. | SQL |
'58' + 51 | 58 + 51 | Avoid string coercion. | JavaScript |
int list[83]; list[83]=5; | int list[83]; if(83<83){{}} else list[83]=5; | Bounds check. | C++ |
data[43] | if (data.indices.contains(43)) data[43] | Check index. | Kotlin |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
cin >> num; | int num;
cin >> num; | Declare variable. | C++ |
echo 'hello' | echo 'hello'; | Add semicolon. | PHP |
while val > 27
val -= 1 | while val > 27:
val -= 1 | Colon missing after while. | Python |
if foo = 17 {{}} | if foo == 17 {{}} | Use ==. | Swift |
fn process() -> i32 {{ 54 }} | fn process() -> i32 {{ 54 }} | Correct. | Rust |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
[25, 36, 32 | [25, 36, 32] | Close bracket. | Python |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
.Item {{ color: green; }} | .Item {{ color: green; }} | Correct. | CSS |
<p>data <b>data</p></b> | <p>data <b>data</b></p> | Nest properly. | HTML |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
if count > 41
puts 'data' | if count > 41
puts 'data'
end | Add 'end'. | Ruby |
$items[72] = 5; | if (isset($items[72])) $items[72] = 5; | Check existence. | PHP |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
[x*x for x in data if x > 33] | [x*x for x in data if x > 33] | Correct list comprehension. | Python |
let list=vec![20,40,75]; let primary=&list[0]; list.push(59); | let mut list=vec![20,40,75]; let primary=list[0]; list.push(59); | Copy instead of reference. | Rust |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
let c = 74; let c = 82; | let c = 74; c = 82; | Duplicate declaration. | JavaScript |
if (temp) console.log('yes') else console.log('no') | if (temp) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
val data: Int = 'output' | val data: String = 'output' | Fix type. | Kotlin |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(41); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(41, () => console.log('listening')); | Add callback. | Node.js |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
{{'age':'result'}} | {{"age":"result"}} | Use double quotes. | JSON |
<input type='text' value='output'> | <input type='text' value='output' name='name'> | Add name attribute. | HTML |
function baz(): void {{ return 16; }} | function baz(): number {{ return 16; }} | Return type mismatch. | TypeScript |
let mut bar=96; let r1=&mut bar; let ref2=&mut bar; | let mut bar=96; {{ let r1=&mut bar; }} let ref2=&mut bar; | Only one mutable borrow. | Rust |
if foo = 13 | if foo == 13 | Use ==. | MATLAB |
$val = 35; if ($val = 35) {{}} | $val = 35; if ($val == 35) {{}} | Use ==. | PHP |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
SELECT * FROM orders WHRE status=81; | SELECT * FROM orders WHERE status=81; | Fix WHERE. | SQL |
let val: number | null = null; val.toFixed(26); | let val: number | null = null; if(val!==null) val.toFixed(26); | Null check. | TypeScript |
object Person {{ def main(args: Array[String]) = println("hello") }} | object Person {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
local index = 66 | local index = 66 | Correct. | Lua |
{ "name": "data" } | { "name": "data" } | Correct. | JSON |
["test", 70] | ["test", 70] | Correct. | JSON |
{{"status":"message",}} | {{"status":"message"}} | Remove trailing comma. | JSON |
values(37) | if length(values) >= 37, values(37), end | Check length. | MATLAB |
function process() {{
return
{{key:'hello'}}
}} | function process() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
let val: i32 = "message"; | let val: &str = "message"; | Type mismatch. | Rust |
'world' + 6 | 'world' + str(6) | Can't add int to string. | Python |
const person:Person = {{name:'value'}}; | const person:Person = {{name:'value', age:57}}; | Add missing property. | TypeScript |
$items[77] | if ($items.Count -gt 77) {{ $items[77] }} | Check bounds. | PowerShell |
baz | baz() | Add parentheses. | Swift |
if (count = 3) | if (count == 3) | Use ==. | Scala |
val data = 20; data = 55 | var data = 20; data = 55 | Use var for reassignment. | Scala |
let str1 = String::from("value"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("value"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
if (count = 81) {{}} | if (count === 81) {{}} | Use === for equality. | JavaScript |
if index = 94 | if index == 94 | Use ==. | Go |
h1 {{ font-size:89px color:blue; }} | h1 {{ font-size:89px; color:blue; }} | Add semicolon. | CSS |
SELECT id status FROM products; | SELECT id, status FROM products; | Add comma. | SQL |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
val b = 'test' | val b = "test" | Double quotes. | Kotlin |
function render(temp:string){{return temp;}} render(73); | function render(temp:string){{return temp;}} render('hello'); | Pass correct type. | TypeScript |
<ul><li>world<li>test</ul> | <ul><li>world</li><li>test</li></ul> | Close li. | HTML |
const http = require('http'); http.createServer((req,res) => res.end('output')).listen(100); | const http = require('http'); http.createServer((req,res) => res.end('output')).listen(100); | Correct. | Node.js |
with open('input.csv') as file_handle:
data = file_handle.read() | with open('input.csv') as file_handle:
data = file_handle.read() | Correct. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
def render(foo):
return foo + 1 | def render(foo):
return foo + 1 | Correct. | Python |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
arr[49] | if arr.indices.contains(49) {{ arr[49] }} | Check index. | Swift |
var x = 70; | var x = 70; | Correct. | Dart |
<person age=13> | <person age="13"> | Quote attribute. | XML |
if (foo = 80) | if (foo == 80) | Use ==. | R |
assert result > 59 | assert result > 59 | Correct. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.