wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
[84, 45, 69 | [84, 45, 69] | Close bracket. | Python |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
let v=vec![90,96,93]; let first=&v[0]; v.push(68); | let mut v=vec![90,96,93]; let first=v[0]; v.push(68); | Copy instead of reference. | Rust |
print('data') | print('data') | Correct. | R |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
value: output
title: world, | value: output
title: world | Remove comma. | YAML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
items(75) | if length(items) >= 75, items(75), end | Check length. | MATLAB |
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 |
$values[16] = 5; | if (isset($values[16])) $values[16] = 5; | Check existence. | PHP |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
String name = 'value'; | String name = 'value'; | Correct. | Dart |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if index > 8
puts 'test' | if index > 8
puts 'test'
end | Add 'end'. | Ruby |
if c > 18
print('hello') | if c > 18:
print('hello') | Colon missing after if. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
// comment | /* comment */ | Use /* */. | CSS |
class Person {{ int b; }}
obj.b=5; | class Person {{ public int b; }}
obj.b=5; | Make field public. | Java |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
<person age=10> | <person age="10"> | Quote attribute. | XML |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
index = 2 | index=2 | No spaces. | Shell |
for (b in list) | for (b of list) | for...in iterates keys. | JavaScript |
<hr></hr> | <hr> | Self-closing. | HTML |
val z = 26; z = 21 | var z = 26; z = 21 | Use var for reassignment. | Scala |
match bar {{ 1 => {{}} }} | match bar {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
cin >> y; | int y;
cin >> y; | Declare variable. | C++ |
if (temp = 17) | if (temp == 17) | Use ==. | Scala |
var x = 76; | var x = 76; | Correct. | Dart |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
WHERE id = '27' | WHERE id = 27 | Don't quote integer. | SQL |
if item = 34: | if item == 34: | Use == for comparison. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
let mut y=91; let r1=&mut y; let ref2=&mut y; | let mut y=91; {{ let r1=&mut y; }} let ref2=&mut y; | Only one mutable borrow. | Rust |
if a = 93 {{}} | if a == 93 {{}} | Use ==. | Swift |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(14); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(14, () => console.log('listening')); | Add callback. | Node.js |
var temp int = 'world' | var temp string = 'world' | Type mismatch. | Go |
let x = 91; | let x = 91; | Correct. | JavaScript |
<person name='result'/> | <person name="result"/> | Double quotes. | XML |
for (int i=0; i<11; i++) {{}} | for (int i=0; i<11; i++) {{}} | Correct. | Java |
'53' + 24 | 53 + 24 | Avoid string coercion. | JavaScript |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
INSERT INTO orders VALUES ('world',22) | INSERT INTO orders (id, email) VALUES ('world',22); | Specify columns. | SQL |
<br></br> | <br> | Self-closing. | HTML |
if ($b = 12) {{}} | if ($b -eq 12) {{}} | Use -eq. | PowerShell |
cin >> a
cout << a; | cin >> a;
cout << a; | Add semicolon. | C++ |
render | render() | Add parentheses. | Swift |
if (c) console.log('yes') else console.log('no') | if (c) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
sys.sqrt(60) | import sys
sys.sqrt(60) | Import module first. | Python |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
result = info | result = 'info' | Quote strings. | Python |
if (y = 75) | if (y == 75) | Use ==. | C++ |
<ul><li>data<li>world</ul> | <ul><li>data</li><li>world</li></ul> | Close li. | HTML |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
DELETE FROM items WHERE name=97 | DELETE FROM items WHERE name=97; | Add semicolon. | SQL |
def handle():
print('test') | def handle():
print('test') | Indent function body. | Python |
let msg = String::from("info"); let ref=&msg; msg.push_str("!"); | let mut msg = String::from("info"); let ref=&msg; println!("{{}}", ref); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
void main() {{ print('message') }} | void main() {{ print('message'); }} | Add semicolon. | Dart |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
if [ $y = 68 ]; then | if [ "$y" = 68 ]; then | Quote variable. | Shell |
[x*x for x in items if x > 73] | [x*x for x in items if x > 73] | Correct list comprehension. | Python |
if bar = 70 | if bar == 70 | Use ==. | Ruby |
values[3] | if (length(values) >= 3) values[3] | Check length. | R |
z > 67 & b < 50 | z > 67 and b < 50 | Use 'and' not '&'. | Python |
String b = 'data'; | String b = "data"; | Double quotes. | Java |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
let index = 89; index += 1; | let mut index = 89; index += 1; | Need mut to modify. | Rust |
let b: i32 = "info"; | let b: &str = "info"; | Type mismatch. | Rust |
let num: Int = 'output' | let num: String = 'output' | Fix type. | Swift |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
int x = 'data'; | String x = 'data'; | Type mismatch. | Dart |
int values[49]; values[49]=5; | int values[49]; if(49<49){{}} else values[49]=5; | Bounds check. | C++ |
let result: number = 'info'; | let result: string = 'info'; | Fix type. | TypeScript |
function bar(c:string){{return c;}} bar(55); | function bar(c:string){{return c;}} bar('hello'); | Pass correct type. | TypeScript |
print 'info' | print('info') | print needs parentheses. | Python |
name: output
age: 10 | name: output
age: 10 | Correct. | YAML |
val index = 'info' | val index = "info" | Double quotes. | Kotlin |
disp('result') | disp('result') | Correct. | MATLAB |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
JOIN orders ON products.id = orders.age | JOIN orders ON products.id = orders.age | Correct. | SQL |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
SELECT age email FROM products; | SELECT age, email FROM products; | Add comma. | SQL |
List(97,24,53) | List(97,24,53) | Correct. | Scala |
SELECT * FROM users WHRE status=14; | SELECT * FROM users WHERE status=14; | Fix WHERE. | SQL |
echo message data | echo 'message data' | Quote to prevent splitting. | Shell |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
arr[17] | if arr.indices.contains(17) {{ arr[17] }} | Check index. | Swift |
#header {{ color: #333; }} | #header {{ color: #333; }} | Correct. | CSS |
h1 {{ font-size:1px color:#fff; }} | h1 {{ font-size:1px; color:#fff; }} | Add semicolon. | CSS |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
const count; | const count = 68; | Initialize const. | JavaScript |
<user><age>hello</age><age>20</age></user | <user><age>hello</age><age>20</age></user> | Add closing >. | XML |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
const bar = 6; bar = 26; | let bar = 6; bar = 26; | Cannot reassign const. | JavaScript |
const obj:Person = {{name:'test'}}; | const obj:Person = {{name:'test', age:30}}; | Add missing property. | TypeScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.