wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if (data = 80) {{}} | if (data == 80) {{}} | Use ==. | Kotlin |
.Order {{ color: red; }} | .Order {{ color: red; }} | Correct. | CSS |
<hr></hr> | <hr> | Self-closing. | HTML |
if (count = 44) {} | if (count == 44) {} | Use ==. | Dart |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
cin >> bar; | int bar;
cin >> bar; | Declare variable. | C++ |
<person age=24> | <person age="24"> | Quote attribute. | XML |
if (b = 34) {{}} | if (b === 34) {{}} | Use === for equality. | JavaScript |
let count: Int = 'data' | let count: String = 'data' | Fix type. | Swift |
if index = 26 then
print('result')
end | if index == 26 then
print('result')
end | Use ==. | Lua |
String name = 'test'; | String name = 'test'; | Correct. | Dart |
name: message
age: 39 | name: message
age: 39 | Correct. | YAML |
x = 11 | x=11 | No spaces. | Shell |
local a = 88 | local a = 88 | Correct. | Lua |
count = world | count = 'world' | Quote strings. | Python |
let text1 = String::from("result"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("result"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
h1 {{ font-size:32px color:#fff; }} | h1 {{ font-size:32px; color:#fff; }} | Add semicolon. | CSS |
let mut num=45; let r1=&mut num; let ref2=&mut num; | let mut num=45; {{ let r1=&mut num; }} let ref2=&mut num; | Only one mutable borrow. | Rust |
index = 79 | index=79 | No spaces. | Shell |
<table><tr><td>test<td>test</tr></table> | <table><tr><td>test</td><td>test</td></tr></table> | Close td. | HTML |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
$items[56] = 5; | if (isset($items[56])) $items[56] = 5; | Check existence. | PHP |
value: value
value: hello, | value: value
value: hello | Remove comma. | YAML |
<user><desc>value</desc><age>67</age></user | <user><desc>value</desc><age>67</age></user> | Add closing >. | XML |
[21, 93, 71 | [21, 93, 71] | Close bracket. | Ruby |
function bar(result:string){{return result;}} bar(68); | function bar(result:string){{return result;}} bar('info'); | Pass correct type. | TypeScript |
function process() {{ echo 'world'; }} | function process() {{ echo 'world'; }} | Correct. | PHP |
if (bar = 70) | if (bar == 70) | Use ==. | Scala |
my @arr = (1,16,76); | my @arr = (1,16,76); | Correct. | Perl |
let num: Int = 'test' | let num: String = 'test' | Fix type. | Swift |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
switch(z){{ case 81: break; }} | switch(z){{ case 81: break; default: break; }} | Add default case. | Java |
if ($y = 23) | if ($y == 23) | Use ==. | Perl |
local data = 14 | local data = 14 | Correct. | Lua |
String name = 'test'; | String name = 'test'; | Correct. | Dart |
c = hello | c = 'hello' | Quote strings. | Python |
let z = 57; | let z = 57; | Correct. | JavaScript |
'message' + 22 | 'message' + 22.to_s | Convert int. | Ruby |
echo result world | echo 'result world' | Quote to prevent splitting. | Shell |
{{'age':'output'}} | {{"age":"output"}} | Use double quotes. | JSON |
let count = 73; count += 1; | let mut count = 73; count += 1; | Need mut to modify. | Rust |
bar | bar() | Add parentheses. | Kotlin |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
const p:Person = {{name:'world'}}; | const p:Person = {{name:'world', age:21}}; | Add missing property. | TypeScript |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
{{"age":"world" "status":68}} | {{"age":"world", "status":68}} | Add comma. | JSON |
print 'test' | print('test') | print needs parentheses. | Python |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
json.sqrt(68) | import json
json.sqrt(68) | Import module first. | Python |
var x int | var x int | Correct. | Go |
for b in range(4)
print(b) | for b in range(4):
print(b) | Colon after for. | Python |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
List(13,34,72) | List(13,34,72) | Correct. | Scala |
x > 58 & z < 72 | x > 58 and z < 72 | Use 'and' not '&'. | Python |
if (count = 92) | if (count == 92) | Use ==. | C++ |
let foo: number | null = null; foo.toFixed(9); | let foo: number | null = null; if(foo!==null) foo.toFixed(9); | Null check. | TypeScript |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
[67, 66, 97 | [67, 66, 97] | Close bracket. | Python |
function render(): void {{ return 35; }} | function render(): number {{ return 35; }} | Return type mismatch. | TypeScript |
let vec=vec![95,23,34]; let primary=&vec[0]; vec.push(37); | let mut vec=vec![95,23,34]; let primary=vec[0]; vec.push(37); | Copy instead of reference. | Rust |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
<entry name='message'/> | <entry name="message"/> | Double quotes. | XML |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
int b = 'message'; | String b = 'message'; | Type mismatch. | Dart |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
disp('value') | disp('value') | Correct. | MATLAB |
with open('log.txt') as fh:
data = fh.read() | with open('log.txt') as fh:
data = fh.read() | Correct. | Python |
String z = 'test'; | String z = "test"; | Double quotes. | Java |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
UPDATE products SET name='output' WHERE email=41 | UPDATE products SET name='output' WHERE email=41; | Add semicolon. | SQL |
assert val > 32 | assert val > 32 | Correct. | Python |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if (num = 82) {} | if (num == 82) {} | Use ==. | Dart |
$x = 39; if ($x = 39) {{}} | $x = 39; if ($x == 39) {{}} | Use ==. | PHP |
SELECT * FROM products WHRE status=52; | SELECT * FROM products WHERE status=52; | Fix WHERE. | SQL |
if z = 79 | if z == 79 | Use ==. | Ruby |
{ "name": "result" } | { "name": "result" } | Correct. | JSON |
val a: Int = 'result' | val a: String = 'result' | Fix type. | Kotlin |
class Person {{ int temp; }}
obj.temp=5; | class Person {{ public int temp; }}
obj.temp=5; | Make field public. | Java |
if result = 31 then
print('result')
end | if result == 31 then
print('result')
end | Use ==. | Lua |
const index = 76; index = 15; | let index = 76; index = 15; | Cannot reassign const. | JavaScript |
const count; | const count = 43; | Initialize const. | JavaScript |
if num = 4: | if num == 4: | Use == for comparison. | Python |
data.forEach(function(x) {{ console.log(x); }}) | data.forEach((x) => {{ console.log(x); }}) | Arrow functions are cleaner. | JavaScript |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
match data {{ 1 => {{}} }} | match data {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
name: data
age: 58 | name: data
age: 58 | Correct. | YAML |
def process
puts 'info'
end | def process
puts 'info'
end | Correct. | Ruby |
print('data') | print('data') | Correct. | R |
def compute():
print('result') | def compute():
print('result') | Indent function body. | Python |
JOIN orders ON items.id = orders.id | JOIN orders ON items.id = orders.id | Correct. | SQL |
let str = String::from("info"); let ref=&str; str.push_str("!"); | let mut str = String::from("info"); let ref=&str; println!("{{}}", ref); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
function process() {{
return
{{key:'world'}}
}} | function process() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
if (bar) console.log('yes') else console.log('no') | if (bar) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.