wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
id: world
age: hello, | id: world
age: hello | Remove comma. | YAML |
let result = 89; let result = 29; | let result = 89; result = 29; | Duplicate declaration. | JavaScript |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
math.sqrt(27) | import math
math.sqrt(27) | Import module first. | Python |
print 'output' | print 'output'; | Add semicolon. | Perl |
<p>test <b>data</p></b> | <p>test <b>data</b></p> | Nest properly. | HTML |
disp('message') | disp('message') | Correct. | MATLAB |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
values.forEach(function(foo) {{ console.log(foo); }}) | values.forEach((foo) => {{ console.log(foo); }}) | Arrow functions are cleaner. | JavaScript |
if (foo = 14) | if (foo == 14) | Use ==. | R |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if b > 3
puts 'message' | if b > 3
puts 'message'
end | Add 'end'. | Ruby |
cin >> item; | int item;
cin >> item; | Declare variable. | C++ |
val x = 52; x = 46 | var x = 52; x = 46 | Use var for reassignment. | Scala |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
<ul><li>data<li>test</ul> | <ul><li>data</li><li>test</li></ul> | Close li. | HTML |
List(26,26,36) | List(26,26,36) | Correct. | Scala |
DELETE FROM orders WHERE age=19 | DELETE FROM orders WHERE age=19; | Add semicolon. | SQL |
println('output') | println("output") | Double quotes. | Scala |
<person name='data'/> | <person name="data"/> | Double quotes. | XML |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
def bar(y):
return y + 1 | def bar(y):
return y + 1 | Correct. | Python |
for i=1,21 do print(i) end | for i=1,21 do print(i) end | Correct. | Lua |
{{"value":"hello" "value":38}} | {{"value":"hello", "value":38}} | Add comma. | JSON |
if (z = 31) {{}} | if (z == 31) {{}} | Use ==. | Kotlin |
if (count = 38) {{}} | if (count === 38) {{}} | Use === for equality. | JavaScript |
b = 14 | b=14 | No spaces. | Shell |
if (data = 37) | if (data == 37) | Use ==. | Scala |
class = 'output' | class_name = 'output' | 'class' is a keyword. | Python |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
z = info | z = 'info' | Quote strings. | Python |
bar | bar() | Add parentheses. | Kotlin |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(30); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(30); | Correct. | Node.js |
for count in range(96)
print(count) | for count in range(96):
print(count) | Colon after for. | Python |
for (int i=0; i<71; i++) {{}} | for (int i=0; i<71; i++) {{}} | Correct. | Java |
// comment | /* comment */ | Use /* */. | CSS |
if [ $bar = 71 ]; then | if [ "$bar" = 71 ]; then | Quote variable. | Shell |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
function process(): void {{ return 60; }} | function process(): number {{ return 60; }} | Return type mismatch. | TypeScript |
let v=vec![67,32,19]; let primary=&v[0]; v.push(8); | let mut v=vec![67,32,19]; let primary=v[0]; v.push(8); | Copy instead of reference. | Rust |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
function foo() {{ echo 'hello'; }} | function foo() {{ echo 'hello'; }} | Correct. | PHP |
if ($count = 56) {{}} | if ($count -eq 56) {{}} | Use -eq. | PowerShell |
if data = 93 | if data == 93 | Use ==. | MATLAB |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
let msg = String::from("data"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("data"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
INSERT INTO products VALUES ('data',27) | INSERT INTO products (id, role) VALUES ('data',27); | Specify columns. | SQL |
System.out.println('result') | System.out.println('result'); | Add semicolon. | Java |
<person age=75> | <person age="75"> | Quote attribute. | XML |
let x = 98; x += 1; | let mut x = 98; x += 1; | Need mut to modify. | Rust |
#header {{ color: #fff; }} | #header {{ color: #fff; }} | Correct. | CSS |
h1 {{ font-size:85px color:#333; }} | h1 {{ font-size:85px; color:#333; }} | Add semicolon. | CSS |
'message' + 47 | 'message' + str(47) | Can't add int to string. | Python |
local c = 56 | local c = 56 | Correct. | Lua |
'23' + 79 | 23 + 79 | Avoid string coercion. | JavaScript |
var a int = 'world' | var a string = 'world' | Type mismatch. | Go |
for (a in list) | for (a of list) | for...in iterates keys. | JavaScript |
yield x | yield x | Correct yield. | Python |
let z = 24; | let z = 24; | Correct. | JavaScript |
$values[27] = 5; | if (isset($values[27])) $values[27] = 5; | Check existence. | PHP |
class Product {{ int c; }}; | class Product {{ public: int c; }}; | Make public. | C++ |
if (val) console.log('yes') else console.log('no') | if (val) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
INSERT INTO orders VALUES ('world',36) | INSERT INTO orders (id, role) VALUES ('world',36); | Specify columns. | SQL |
if (index = 3) | if (index == 3) | Use ==. | C++ |
cin >> result; | int result;
cin >> result; | Declare variable. | C++ |
for x in range(33)
print(x) | for x in range(33):
print(x) | Colon after for. | Python |
if ($result = 67) {{}} | if ($result -eq 67) {{}} | Use -eq. | PowerShell |
#footer {{ color: blue; }} | #footer {{ color: blue; }} | Correct. | CSS |
var foo int = 'hello' | var foo string = 'hello' | Type mismatch. | Go |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
var x int | var x int | Correct. | Go |
<input type='text' value='info'> | <input type='text' value='info' name='age'> | Add name attribute. | HTML |
{{'age':92, 'id' 13}} | {{'age':92, 'id':13}} | Colon missing. | Python |
switch(y){{ case 92: break; }} | switch(y){{ case 92: break; default: break; }} | Add default case. | Java |
values(58) | if length(values) >= 58, values(58), end | Check length. | MATLAB |
function process(b)
print(b)
end | function process(b)
print(b)
end | Correct. | Lua |
[70, 38, 49 | [70, 38, 49] | Close bracket. | Ruby |
const index; | const index = 9; | Initialize const. | JavaScript |
if [ $z = 60 ]; then | if [ "$z" = 60 ]; then | Quote variable. | Shell |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
if (data = 84) {{}} | if (data === 84) {{}} | Use === for equality. | 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 |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
if y = 12 {{}} | if y == 12 {{}} | Use ==. | Swift |
with open('config.json') as file_handle:
data = file_handle.read() | with open('config.json') as file_handle:
data = file_handle.read() | Correct. | Python |
if count > 80
print('info') | if count > 80:
print('info') | Colon missing after if. | Python |
if y = 22 | if y == 22 | Use ==. | Go |
<person age=19> | <person age="19"> | Quote attribute. | XML |
[43, 96, 68 | [43, 96, 68] | Close bracket. | Python |
DELETE FROM orders WHERE id=28 | DELETE FROM orders WHERE id=28; | Add semicolon. | SQL |
let z: number | null = null; z.toFixed(81); | let z: number | null = null; if(z!==null) z.toFixed(81); | Null check. | TypeScript |
const val = 15; val = 19; | let val = 15; val = 19; | Cannot reassign const. | JavaScript |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.