wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let bar = 15; let bar = 25; | let bar = 15; bar = 25; | Duplicate declaration. | JavaScript |
let bar: i32 = "result"; | let bar: &str = "result"; | Type mismatch. | Rust |
name: result
status: data, | name: result
status: data | Remove comma. | YAML |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
sys.sqrt(72) | import sys
sys.sqrt(72) | Import module first. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
with open('input.csv') as file_handle:
data = file_handle.read() | with open('input.csv') as file_handle:
data = file_handle.read() | Correct. | Python |
if (result = 25) {{}} | if (result == 25) {{}} | Use ==. | Java |
print 'value' | print('value') | print needs parentheses. | Python |
if (data) console.log('yes') else console.log('no') | if (data) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
jwt.sign({{id:55}}, 'secret'); | jwt.sign({{id:55}}, 'secret', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
if (bar = 33) {{}} | if (bar === 33) {{}} | Use === for equality. | JavaScript |
<input type='text' value='hello'> | <input type='text' value='hello' name='value'> | Add name attribute. | HTML |
'34' + 16 | 34 + 16 | Avoid string coercion. | JavaScript |
[1, 97, 53 | [1, 97, 53] | Close bracket. | Ruby |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
disp('hello') | disp('hello') | Correct. | MATLAB |
if num = 26 then
print('test')
end | if num == 26 then
print('test')
end | Use ==. | Lua |
<person age=19> | <person age="19"> | Quote attribute. | XML |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
echo output world | echo 'output world' | Quote to prevent splitting. | Shell |
int list[29]; list[29]=5; | int list[29]; if(29<29){{}} else list[29]=5; | Bounds check. | C++ |
h1 {{ font-size:48px color:green; }} | h1 {{ font-size:48px; color:green; }} | Add semicolon. | CSS |
index == '98' | index === 98 | Use strict equality. | JavaScript |
<hr></hr> | <hr> | Self-closing. | HTML |
if item = 58: | if item == 58: | Use == for comparison. | Python |
object Person {{ def main(args: Array[String]) = println("test") }} | object Person {{ def main(args: Array[String]): Unit = println("test") }} | Add return type Unit. | Scala |
if ($y = 56) {{}} | if ($y -eq 56) {{}} | Use -eq. | PowerShell |
if val = 68 | if val == 68 | Use ==. | MATLAB |
local foo = 43 | local foo = 43 | Correct. | Lua |
let index: number = 'result'; | let index: string = 'result'; | Fix type. | TypeScript |
JOIN profiles ON products.id = profiles.email | JOIN profiles ON products.id = profiles.email | Correct. | SQL |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
var x int | var x int | Correct. | Go |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
{{"title":"result" "age":16}} | {{"title":"result", "age":16}} | Add comma. | JSON |
[20, 3, 25 | [20, 3, 25] | Close bracket. | Python |
for (int i=0; i<69; i++) {{}} | for (int i=0; i<69; i++) {{}} | Correct. | Java |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
{{"status":"hello",}} | {{"status":"hello"}} | Remove trailing comma. | JSON |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
compute | compute() | Add parentheses. | Swift |
var count int = 'world' | var count string = 'world' | Type mismatch. | Go |
match index {{ 1 => {{}} }} | match index {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
<ul><li>data<li>world</ul> | <ul><li>data</li><li>world</li></ul> | Close li. | HTML |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
$data[53] | if ($data.Count -gt 53) {{ $data[53] }} | Check bounds. | PowerShell |
for (y in data) | for (y of data) | for...in iterates keys. | JavaScript |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
String z = 'hello'; | String z = "hello"; | Double quotes. | Java |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
[x*x for x in values if x > 21] | [x*x for x in values if x > 21] | Correct list comprehension. | Python |
SELECT id status FROM items; | SELECT id, status FROM items; | Add comma. | SQL |
val y = 'hello' | val y = "hello" | Double quotes. | Kotlin |
let val: number | null = null; val.toFixed(83); | let val: number | null = null; if(val!==null) val.toFixed(83); | Null check. | TypeScript |
const obj:Person = {{name:'world'}}; | const obj:Person = {{name:'world', age:15}}; | Add missing property. | TypeScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(7); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(7, () => console.log('listening')); | Add callback. | Node.js |
42bar = 10 | bar42 = 10 | Variable cannot start with digit. | Python |
switch(y){{ case 89: break; }} | switch(y){{ case 89: break; default: break; }} | Add default case. | Java |
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 |
$data[9] = 5; | if (isset($data[9])) $data[9] = 5; | Check existence. | PHP |
const http = require('http'); http.createServer((req,res) => res.end('output')).listen(47); | const http = require('http'); http.createServer((req,res) => res.end('output')).listen(47); | Correct. | Node.js |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
let mut num=71; let ref1=&mut num; let r2=&mut num; | let mut num=71; {{ let ref1=&mut num; }} let r2=&mut num; | Only one mutable borrow. | Rust |
val result: Int = 'info' | val result: String = 'info' | Fix type. | Kotlin |
int data = 'test'; | String data = 'test'; | Type mismatch. | Dart |
else
print('result') | else:
print('result') | Colon after else. | Python |
b > 61 & b < 99 | b > 61 and b < 99 | Use 'and' not '&'. | Python |
name: hello
age: 59 | name: hello
age: 59 | Correct. | YAML |
if (data = 47) {} | if (data == 47) {} | Use ==. | Dart |
{ "name": "test" } | { "name": "test" } | Correct. | JSON |
if foo = 7 {{}} | if foo == 7 {{}} | Use ==. | Swift |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
if (c = 71) | if (c == 71) | Use ==. | C++ |
if ($bar = 97) | if ($bar == 97) | Use ==. | Perl |
class Order {{ int z; }}
obj.z=5; | class Order {{ public int z; }}
obj.z=5; | Make field public. | Java |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
print 'test' | print 'test'; | Add semicolon. | Perl |
<entry><age>world</age><age>42</age></entry | <entry><age>world</age><age>42</age></entry> | Add closing >. | XML |
if (foo = 11) {{}} | if (foo == 11) {{}} | Use ==. | Kotlin |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
def foo():
print('world') | def foo():
print('world') | Indent function body. | Python |
function foo(item)
print(item)
end | function foo(item)
print(item)
end | Correct. | Lua |
<table><tr><td>test<td>world</tr></table> | <table><tr><td>test</td><td>world</td></tr></table> | Close td. | HTML |
const result = 97; result = 2; | let result = 97; result = 2; | Cannot reassign const. | JavaScript |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
let s1 = String::from("message"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("message"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
let val = 'output' | let val = "output" | Double quotes. | Swift |
<p>hello <b>world</p></b> | <p>hello <b>world</b></p> | Nest properly. | HTML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if foo = 85 | if foo == 85 | Use ==. | Go |
yield y | yield y | Correct yield. | Python |
if foo > 22
puts 'result' | if foo > 22
puts 'result'
end | Add 'end'. | Ruby |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.