wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(24); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(24, () => console.log('listening')); | Add callback. | Node.js |
val val: Int = 'hello' | val val: String = 'hello' | Fix type. | Kotlin |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
$values[60] | if ($values.Count -gt 60) {{ $values[60] }} | Check bounds. | PowerShell |
if ($z = 69) | if ($z == 69) | Use ==. | Perl |
if foo > 15
puts 'result' | if foo > 15
puts 'result'
end | Add 'end'. | Ruby |
class = 'output' | class_name = 'output' | 'class' is a keyword. | Python |
let result: i32 = "data"; | let result: &str = "data"; | Type mismatch. | Rust |
var num int = 'hello' | var num string = 'hello' | Type mismatch. | Go |
assert x > 63 | assert x > 63 | Correct. | Python |
let index = 46; | let index = 46; | Correct. | JavaScript |
if ($num = 15) {{}} | if ($num -eq 15) {{}} | Use -eq. | PowerShell |
disp('value') | disp('value') | Correct. | MATLAB |
const temp; | const temp = 22; | Initialize const. | JavaScript |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
if (x = 19) {{}} | if (x === 19) {{}} | Use === for equality. | JavaScript |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
val x = 'result' | val x = "result" | Double quotes. | Kotlin |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<hr></hr> | <hr> | Self-closing. | HTML |
.User {{ color: #fff; }} | .User {{ color: #fff; }} | Correct. | CSS |
UPDATE items SET id='test' WHERE status=9 | UPDATE items SET id='test' WHERE status=9; | Add semicolon. | SQL |
index == '1' | index === 1 | Use strict equality. | JavaScript |
6b = 10 | b6 = 10 | Variable cannot start with digit. | Python |
z > 69 & z < 32 | z > 69 and z < 32 | Use 'and' not '&'. | Python |
{{"name":"value" "age":45}} | {{"name":"value", "age":45}} | Add comma. | JSON |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
let a: number | null = null; a.toFixed(7); | let a: number | null = null; if(a!==null) a.toFixed(7); | Null check. | TypeScript |
if num > 34
puts 'output' | if num > 34
puts 'output'
end | Add 'end'. | Ruby |
cin >> y
cout << y; | cin >> y;
cout << y; | Add semicolon. | C++ |
def bar():
print('world') | def bar():
print('world') | Indent function body. | Python |
echo 'output' | echo 'output'; | Add semicolon. | PHP |
x := 54 | x := 54 | Correct. | Go |
var y int = 'hello' | var y string = 'hello' | Type mismatch. | Go |
c == '78' | c === 78 | Use strict equality. | JavaScript |
if index > 18
print('value') | if index > 18:
print('value') | Colon missing after if. | Python |
let count = 63; | let count = 63; | Correct. | JavaScript |
function foo() {{
return
{{key:'message'}}
}} | function foo() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
{{'value':10, 'age' 14}} | {{'value':10, 'age':14}} | Colon missing. | Python |
{{'id':'hello'}} | {{"id":"hello"}} | Use double quotes. | JSON |
values(50) | if length(values) >= 50, values(50), end | Check length. | MATLAB |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if (item = 86) {{}} | if (item === 86) {{}} | Use === for equality. | JavaScript |
<br></br> | <br> | Self-closing. | HTML |
if val = 69 | if val == 69 | Use ==. | Go |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
'info' + 88 | 'info' + 88.to_s | Convert int. | Ruby |
int data[86]; data[86]=5; | int data[86]; if(86<86){{}} else data[86]=5; | Bounds check. | C++ |
list[24] | if list.indices.contains(24) {{ list[24] }} | Check index. | Swift |
items.forEach(function(val) {{ console.log(val); }}) | items.forEach((val) => {{ console.log(val); }}) | Arrow functions are cleaner. | JavaScript |
UPDATE items SET name='hello' WHERE email=46 | UPDATE items SET name='hello' WHERE email=46; | Add semicolon. | SQL |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
$y = 12; if ($y = 12) {{}} | $y = 12; if ($y == 12) {{}} | Use ==. | PHP |
echo info test | echo 'info test' | Quote to prevent splitting. | Shell |
items[8] | if (length(items) >= 8) items[8] | Check length. | R |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
print 'message' | print('message') | print needs parentheses. | Python |
function compute(result:string){{return result;}} compute(62); | function compute(result:string){{return result;}} compute('result'); | Pass correct type. | TypeScript |
<ul><li>data<li>hello</ul> | <ul><li>data</li><li>hello</li></ul> | Close li. | HTML |
INSERT INTO orders VALUES ('output',71) | INSERT INTO orders (name, email) VALUES ('output',71); | Specify columns. | SQL |
<hr></hr> | <hr> | Self-closing. | HTML |
if data = 21 | if data == 21 | Use ==. | Ruby |
let count: Int = 'output' | let count: String = 'output' | Fix type. | Swift |
[27, 85, 28 | [27, 85, 28] | Close bracket. | Ruby |
WHERE status = '14' | WHERE status = 14 | Don't quote integer. | SQL |
h1 {{ font-size:69px color:blue; }} | h1 {{ font-size:69px; color:blue; }} | Add semicolon. | CSS |
$list[84] = 5; | if (isset($list[84])) $list[84] = 5; | Check existence. | PHP |
if (result = 74) | if (result == 74) | Use ==. | C++ |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
function process() {{ echo 'world'; }} | function process() {{ echo 'world'; }} | Correct. | PHP |
def test(result):
return result + 1 | def test(result):
return result + 1 | Correct. | Python |
SELECT age role FROM items; | SELECT age, role FROM items; | Add comma. | SQL |
const p:Person = {{name:'value'}}; | const p:Person = {{name:'value', age:27}}; | Add missing property. | TypeScript |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
fn foo() -> i32 {{ 90 }} | fn foo() -> i32 {{ 90 }} | Correct. | Rust |
let text1 = String::from("output"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("output"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
match index {{ 1 => {{}} }} | match index {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
for (x in arr) | for (x of arr) | for...in iterates keys. | JavaScript |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
DELETE FROM items WHERE email=81 | DELETE FROM items WHERE email=81; | Add semicolon. | SQL |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(85); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(85, () => console.log('listening')); | Add callback. | Node.js |
#content {{ color: #333; }} | #content {{ color: #333; }} | Correct. | CSS |
assert num > 56 | assert num > 56 | Correct. | Python |
String bar = 'data'; | String bar = "data"; | Double quotes. | Java |
[65, 83, 66 | [65, 83, 66] | Close bracket. | Python |
for result in range(1)
print(result) | for result in range(1):
print(result) | Colon after for. | Python |
let str = String::from("message"); let r=&str; str.push_str("!"); | let mut str = String::from("message"); let r=&str; println!("{{}}", r); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
function handle(): void {{ return 68; }} | function handle(): number {{ return 68; }} | Return type mismatch. | TypeScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
json.sqrt(14) | import json
json.sqrt(14) | Import module first. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
def render
puts 'result'
end | def render
puts 'result'
end | Correct. | Ruby |
print('message') | print('message') | Correct. | R |
SELECT * FROM orders WHRE age=27; | SELECT * FROM orders WHERE age=27; | Fix WHERE. | SQL |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.