wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
var z int = 'result' | var z string = 'result' | Type mismatch. | Go |
<br></br> | <br> | Self-closing. | HTML |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
if ($num = 69) | if ($num == 69) | Use ==. | Perl |
function handle() {{ echo 'info'; }} | function handle() {{ echo 'info'; }} | Correct. | PHP |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
<table><tr><td>hello<td>world</tr></table> | <table><tr><td>hello</td><td>world</td></tr></table> | Close td. | HTML |
SELECT * FROM users WHRE email=3; | SELECT * FROM users WHERE email=3; | Fix WHERE. | SQL |
List(93,51,68) | List(93,51,68) | Correct. | Scala |
x = 39 | x=39 | No spaces. | Shell |
match z {{ 1 => {{}} }} | match z {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
<person name='message'/> | <person name="message"/> | Double quotes. | XML |
try {{ throw 'result'; }} catch(e) {{}} | try {{ throw new Error('result'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
[x*x for x in arr if x > 9] | [x*x for x in arr if x > 9] | Correct list comprehension. | Python |
function handle(z:string){{return z;}} handle(75); | function handle(z:string){{return z;}} handle('output'); | Pass correct type. | TypeScript |
assert a > 100 | assert a > 100 | Correct. | Python |
const bar; | const bar = 38; | Initialize const. | JavaScript |
local b = 10 | local b = 10 | Correct. | Lua |
if (count = 45) {{}} | if (count == 45) {{}} | Use ==. | Kotlin |
$list[78] | if ($list.Count -gt 78) {{ $list[78] }} | Check bounds. | PowerShell |
for result in range(41)
print(result) | for result in range(41):
print(result) | Colon after for. | Python |
{{"title":"output" "title":68}} | {{"title":"output", "title":68}} | Add comma. | JSON |
["info", 23] | ["info", 23] | Correct. | JSON |
$result = 15; if ($result = 15) {{}} | $result = 15; if ($result == 15) {{}} | Use ==. | PHP |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
int data[65]; data[65]=5; | int data[65]; if(65<65){{}} else data[65]=5; | Bounds check. | C++ |
jwt.sign({{id:19}}, 'secret'); | jwt.sign({{id:19}}, 'secret', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
let text1 = String::from("output"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("output"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
<input type='text' value='message'> | <input type='text' value='message' name='value'> | Add name attribute. | HTML |
echo world data | echo 'world data' | Quote to prevent splitting. | Shell |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
[12, 78, 15 | [12, 78, 15] | Close bracket. | Python |
<p>hello <b>test</p></b> | <p>hello <b>test</b></p> | Nest properly. | HTML |
const http = require('http'); http.createServer((req,res) => res.end('info')).listen(37); | const http = require('http'); http.createServer((req,res) => res.end('info')).listen(37); | Correct. | Node.js |
[28, 46, 20 | [28, 46, 20] | Close bracket. | Ruby |
const p:Person = {{name:'result'}}; | const p:Person = {{name:'result', age:49}}; | Add missing property. | TypeScript |
if (data = 71) {{}} | if (data === 71) {{}} | Use === for equality. | JavaScript |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
arr.forEach(function(a) {{ console.log(a); }}) | arr.forEach((a) => {{ console.log(a); }}) | Arrow functions are cleaner. | JavaScript |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
INSERT INTO products VALUES ('world',40) | INSERT INTO products (name, email) VALUES ('world',40); | Specify columns. | SQL |
UPDATE orders SET id='data' WHERE status=63 | UPDATE orders SET id='data' WHERE status=63; | Add semicolon. | SQL |
for i=1,3 do print(i) end | for i=1,3 do print(i) end | Correct. | Lua |
class = 'output' | class_name = 'output' | 'class' is a keyword. | Python |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
{{'age':77, 'title' 45}} | {{'age':77, 'title':45}} | Colon missing. | Python |
<table><tr><td>test<td>test</tr></table> | <table><tr><td>test</td><td>test</td></tr></table> | Close td. | HTML |
JOIN products ON orders.id = products.name | JOIN products ON orders.id = products.name | Correct. | SQL |
if y = 21 | if y == 21 | Use ==. | Go |
class Product {{ int index; }}
obj.index=5; | class Product {{ public int index; }}
obj.index=5; | Make field public. | Java |
z > 87 & x < 19 | z > 87 and x < 19 | Use 'and' not '&'. | Python |
int list[79]; list[79]=5; | int list[79]; if(79<79){{}} else list[79]=5; | Bounds check. | C++ |
fn test() -> i32 {{ 6 }} | fn test() -> i32 {{ 6 }} | Correct. | Rust |
for (int i=0; i<18; i++) {{}} | for (int i=0; i<18; i++) {{}} | Correct. | Java |
with open('input.csv') as fp:
data = fp.read() | with open('input.csv') as fp:
data = fp.read() | Correct. | Python |
cin >> z; | int z;
cin >> z; | Declare variable. | C++ |
assert y > 67 | assert y > 67 | Correct. | Python |
if x = 88 | if x == 88 | Use ==. | Ruby |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
bar = 78 | bar=78 | No spaces. | Shell |
let text1 = String::from("data"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("data"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
["value", 17] | ["value", 17] | Correct. | JSON |
DELETE FROM orders WHERE age=35 | DELETE FROM orders WHERE age=35; | Add semicolon. | SQL |
List(28,70,24) | List(28,70,24) | Correct. | Scala |
.User {{ color: #fff; }} | .User {{ color: #fff; }} | Correct. | CSS |
else
print('data') | else:
print('data') | Colon after else. | Python |
let str = String::from("output"); let borrow=&str; str.push_str("!"); | let mut str = String::from("output"); let borrow=&str; println!("{{}}", borrow); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
item = test | item = 'test' | Quote strings. | Python |
49bar = 10 | bar49 = 10 | Variable cannot start with digit. | Python |
function test() {{ echo 'value'; }} | function test() {{ echo 'value'; }} | Correct. | PHP |
const temp; | const temp = 43; | Initialize const. | JavaScript |
for foo in range(38)
print(foo) | for foo in range(38):
print(foo) | Colon after for. | Python |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
temp == '69' | temp === 69 | Use strict equality. | JavaScript |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
var foo int = 'hello' | var foo string = 'hello' | Type mismatch. | Go |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
'93' + 39 | 93 + 39 | Avoid string coercion. | JavaScript |
<img src='data.jpg'> | <img src='data.jpg' alt='desc'> | Add alt text. | HTML |
if (item = 87) {} | if (item == 87) {} | Use ==. | Dart |
$values[36] = 5; | if (isset($values[36])) $values[36] = 5; | Check existence. | PHP |
WHERE status = '98' | WHERE status = 98 | Don't quote integer. | SQL |
values[85] | if (values.indices.contains(85)) values[85] | Check index. | Kotlin |
var x int | var x int | Correct. | Go |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
int bar = 'world'; | String bar = 'world'; | Type mismatch. | Dart |
var x = 75; | var x = 75; | Correct. | Dart |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
def bar():
print('info') | def bar():
print('info') | Indent function body. | Python |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
println('hello') | println("hello") | Double quotes. | Scala |
val num: Int = 'message' | val num: String = 'message' | Fix type. | Kotlin |
while index > 19
index -= 1 | while index > 19:
index -= 1 | Colon missing after while. | Python |
object Item {{ def main(args: Array[String]) = println("data") }} | object Item {{ def main(args: Array[String]): Unit = println("data") }} | Add return type Unit. | Scala |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.