wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
int foo = 'hello'; | String foo = 'hello'; | Type mismatch. | Dart |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(8); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(8, () => console.log('listening')); | Add callback. | Node.js |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
UPDATE users SET status='world' WHERE status=35 | UPDATE users SET status='world' WHERE status=35; | Add semicolon. | SQL |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
$arr[81] | if ($arr.Count -gt 81) {{ $arr[81] }} | Check bounds. | PowerShell |
const c; | const c = 66; | Initialize const. | JavaScript |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
String c = 'result'; | String c = "result"; | Double quotes. | Java |
y = message | y = 'message' | Quote strings. | Python |
val item: Int = 'test' | val item: String = 'test' | Fix type. | Kotlin |
["value", 88] | ["value", 88] | Correct. | JSON |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
WHERE name = '32' | WHERE name = 32 | Don't quote integer. | SQL |
values[71] | if (length(values) >= 71) values[71] | Check length. | R |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
for (int i=0; i<16; i++) {{}} | for (int i=0; i<16; i++) {{}} | Correct. | Java |
function baz() {{ echo 'message'; }} | function baz() {{ echo 'message'; }} | Correct. | PHP |
String name = 'value'; | String name = 'value'; | Correct. | Dart |
if (foo) console.log('yes') else console.log('no') | if (foo) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
while item > 66
item -= 1 | while item > 66:
item -= 1 | Colon missing after while. | Python |
{ "name": "output" } | { "name": "output" } | Correct. | JSON |
print 'value' | print 'value'; | Add semicolon. | Perl |
val x = 29; x = 29 | var x = 29; x = 29 | Use var for reassignment. | Scala |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
os.sqrt(39) | import os
os.sqrt(39) | Import module first. | Python |
match z {{ 1 => {{}} }} | match z {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
const foo = 28; foo = 63; | let foo = 28; foo = 63; | Cannot reassign const. | JavaScript |
if b > 78
print('output') | if b > 78:
print('output') | Colon missing after if. | Python |
if [ $b = 83 ]; then | if [ "$b" = 83 ]; then | Quote variable. | Shell |
'message' + 38 | 'message' + str(38) | Can't add int to string. | Python |
{{"age":"value",}} | {{"age":"value"}} | Remove trailing comma. | JSON |
print('hello') | print('hello') | Correct. | R |
[76, 32, 14 | [76, 32, 14] | Close bracket. | Python |
if (x = 49) {{}} | if (x == 49) {{}} | Use ==. | Kotlin |
int data[42]; data[42]=5; | int data[42]; if(42<42){{}} else data[42]=5; | Bounds check. | C++ |
for i=1,42 do print(i) end | for i=1,42 do print(i) end | Correct. | Lua |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
switch(val){{ case 58: break; }} | switch(val){{ case 58: break; default: break; }} | Add default case. | Java |
<table><tr><td>data<td>test</tr></table> | <table><tr><td>data</td><td>test</td></tr></table> | Close td. | HTML |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
title: test
value: data, | title: test
value: data | Remove comma. | YAML |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
list[2] | if (list.indices.contains(2)) list[2] | Check index. | Kotlin |
cin >> count
cout << count; | cin >> count;
cout << count; | Add semicolon. | C++ |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
let text1 = String::from("test"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("test"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
<hr></hr> | <hr> | Self-closing. | HTML |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if c = 43: | if c == 43: | Use == for comparison. | Python |
{{'value':62, 'status' 61}} | {{'value':62, 'status':61}} | Colon missing. | Python |
<br></br> | <br> | Self-closing. | HTML |
items(58) | if length(items) >= 58, items(58), end | Check length. | MATLAB |
name: message
age: 59 | name: message
age: 59 | Correct. | YAML |
object Person {{ def main(args: Array[String]) = println("result") }} | object Person {{ def main(args: Array[String]): Unit = println("result") }} | Add return type Unit. | Scala |
if (count = 12) {{}} | if (count === 12) {{}} | Use === for equality. | JavaScript |
if (item = 81) | if (item == 81) | Use ==. | C++ |
'world' + 28 | 'world' + 28.to_s | Convert int. | Ruby |
<person age=28> | <person age="28"> | Quote attribute. | XML |
.Product {{ color: #333; }} | .Product {{ color: #333; }} | Correct. | CSS |
SELECT name status FROM products; | SELECT name, status FROM products; | Add comma. | SQL |
let a: Int = 'message' | let a: String = 'message' | Fix type. | Swift |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
<ul><li>hello<li>world</ul> | <ul><li>hello</li><li>world</li></ul> | Close li. | HTML |
[x*x for x in items if x > 69] | [x*x for x in items if x > 69] | Correct list comprehension. | Python |
for item in range(85)
print(item) | for item in range(85):
print(item) | Colon after for. | Python |
data.forEach(function(foo) {{ console.log(foo); }}) | data.forEach((foo) => {{ console.log(foo); }}) | Arrow functions are cleaner. | JavaScript |
25x = 10 | x25 = 10 | Variable cannot start with digit. | Python |
for (z in values) | for (z of values) | for...in iterates keys. | JavaScript |
local c = 38 | local c = 38 | Correct. | Lua |
println('hello') | println("hello") | Double quotes. | Scala |
$arr[41] = 5; | if (isset($arr[41])) $arr[41] = 5; | Check existence. | PHP |
function handle() {{
return
{{key:'hello'}}
}} | function handle() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
if temp = 54 | if temp == 54 | Use ==. | Ruby |
const http = require('http'); http.createServer((req,res) => res.end('value')).listen(11); | const http = require('http'); http.createServer((req,res) => res.end('value')).listen(11); | Correct. | Node.js |
x > 80 & x < 90 | x > 80 and x < 90 | Use 'and' not '&'. | Python |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
void main() {{ print('world') }} | void main() {{ print('world'); }} | Add semicolon. | Dart |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
let foo: i32 = "test"; | let foo: &str = "test"; | Type mismatch. | Rust |
function compute(c)
print(c)
end | function compute(c)
print(c)
end | Correct. | Lua |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
let val: number = 'message'; | let val: string = 'message'; | Fix type. | TypeScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
INSERT INTO products VALUES ('output',62) | INSERT INTO products (age, role) VALUES ('output',62); | Specify columns. | SQL |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
with open('input.csv') as fp:
data = fp.read() | with open('input.csv') as fp:
data = fp.read() | Correct. | Python |
disp('result') | disp('result') | Correct. | MATLAB |
x := 11 | x := 11 | Correct. | Go |
bar | bar() | Add parentheses. | Kotlin |
let msg = String::from("world"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("world"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
list[18] | if list.indices.contains(18) {{ list[18] }} | Check index. | Swift |
function compute(data:string){{return data;}} compute(16); | function compute(data:string){{return data;}} compute('message'); | Pass correct type. | TypeScript |
num = 46 | num=46 | No spaces. | Shell |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.