wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
INSERT INTO users VALUES ('info',30) | INSERT INTO users (name, status) VALUES ('info',30); | Specify columns. | SQL |
class Person {{ int index; }}
obj.index=5; | class Person {{ public int index; }}
obj.index=5; | Make field public. | Java |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if index = 90: | if index == 90: | Use == for comparison. | Python |
if ($bar = 26) {{}} | if ($bar -eq 26) {{}} | Use -eq. | PowerShell |
int data[72]; data[72]=5; | int data[72]; if(72<72){{}} else data[72]=5; | Bounds check. | C++ |
const num; | const num = 4; | Initialize const. | JavaScript |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
let result = 15; | let result = 15; | Correct. | JavaScript |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
#main {{ color: #333; }} | #main {{ color: #333; }} | Correct. | CSS |
{{'id':33, 'age' 11}} | {{'id':33, 'age':11}} | Colon missing. | Python |
if a = 47 | if a == 47 | Use ==. | MATLAB |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
let b: number | null = null; b.toFixed(75); | let b: number | null = null; if(b!==null) b.toFixed(75); | Null check. | TypeScript |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
print 'info' | print 'info'; | Add semicolon. | Perl |
age: result
title: world, | age: result
title: world | Remove comma. | YAML |
let temp: number = 'info'; | let temp: string = 'info'; | Fix type. | TypeScript |
val y = 'data' | val y = "data" | Double quotes. | Kotlin |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(78); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(78, () => console.log('listening')); | Add callback. | Node.js |
function compute(): void {{ return 17; }} | function compute(): number {{ return 17; }} | Return type mismatch. | TypeScript |
x := 49 | x := 49 | Correct. | Go |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
y == '21' | y === 21 | Use strict equality. | JavaScript |
{{'id':'value'}} | {{"id":"value"}} | Use double quotes. | JSON |
let v=vec![50,56,84]; let primary=&v[0]; v.push(72); | let mut v=vec![50,56,84]; let primary=v[0]; v.push(72); | Copy instead of reference. | Rust |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
<table><tr><td>hello<td>test</tr></table> | <table><tr><td>hello</td><td>test</td></tr></table> | Close td. | HTML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
let str1 = String::from("test"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("test"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
def test():
print('data') | def test():
print('data') | Indent function body. | Python |
$num = 79; if ($num = 79) {{}} | $num = 79; if ($num == 79) {{}} | Use ==. | PHP |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
for (c in list) | for (c of list) | for...in iterates keys. | JavaScript |
let result: i32 = "value"; | let result: &str = "value"; | Type mismatch. | Rust |
def handle(x):
return x + 1 | def handle(x):
return x + 1 | Correct. | Python |
if x = 41 {{}} | if x == 41 {{}} | Use ==. | Swift |
function foo(c:string){{return c;}} foo(40); | function foo(c:string){{return c;}} foo('message'); | Pass correct type. | TypeScript |
print('value') | print('value') | Correct. | R |
UPDATE products SET id='output' WHERE status=96 | UPDATE products SET id='output' WHERE status=96; | Add semicolon. | SQL |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
let val: Int = 'message' | let val: String = 'message' | Fix type. | Swift |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
{{"age":"world" "id":56}} | {{"age":"world", "id":56}} | Add comma. | JSON |
<person><name>data</name><desc>84</desc></person | <person><name>data</name><desc>84</desc></person> | Add closing >. | XML |
if (x = 63) {{}} | if (x == 63) {{}} | Use ==. | Kotlin |
'76' + 32 | 76 + 32 | Avoid string coercion. | JavaScript |
console.log('value' | console.log('value') | Close parenthesis. | JavaScript |
bar | bar() | Add parentheses. | Kotlin |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
3x = 10 | x3 = 10 | Variable cannot start with digit. | Python |
val = 9 | val=9 | No spaces. | Shell |
fn baz() -> i32 {{ 52 }} | fn baz() -> i32 {{ 52 }} | Correct. | Rust |
if num > 35
print('value') | if num > 35:
print('value') | Colon missing after if. | Python |
with open('config.json') as fh:
data = fh.read() | with open('config.json') as fh:
data = fh.read() | Correct. | Python |
'message' + 94 | 'message' + str(94) | Can't add int to string. | Python |
$data[59] | if ($data.Count -gt 59) {{ $data[59] }} | Check bounds. | PowerShell |
items[67] | if (items.indices.contains(67)) items[67] | Check index. | Kotlin |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
let str = String::from("world"); let r=&str; str.push_str("!"); | let mut str = String::from("world"); let r=&str; println!("{{}}", r); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
data[8] | if data.indices.contains(8) {{ data[8] }} | Check index. | Swift |
if (c = 41) {{}} | if (c === 41) {{}} | Use === for equality. | JavaScript |
for b in range(47)
print(b) | for b in range(47):
print(b) | Colon after for. | Python |
values.forEach(function(temp) {{ console.log(temp); }}) | values.forEach((temp) => {{ console.log(temp); }}) | Arrow functions are cleaner. | JavaScript |
int[] list = new int[38];
list[38] = 5; | int[] list = new int[38];
if (38 < list.length) list[38] = 5; | Check bounds. | Java |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
h1 {{ font-size:79px color:blue; }} | h1 {{ font-size:79px; color:blue; }} | Add semicolon. | CSS |
cin >> temp
cout << temp; | cin >> temp;
cout << temp; | Add semicolon. | C++ |
match data {{ 1 => {{}} }} | match data {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
<ul><li>data<li>hello</ul> | <ul><li>data</li><li>hello</li></ul> | Close li. | HTML |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
print 'data' | print('data') | print needs parentheses. | Python |
echo 'output' | echo 'output'; | Add semicolon. | PHP |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
else
print('value') | else:
print('value') | Colon after else. | Python |
assert a > 99 | assert a > 99 | Correct. | Python |
for (int i=0; i<77; i++) {{}} | for (int i=0; i<77; i++) {{}} | Correct. | Java |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
my @arr = (30,25,6); | my @arr = (30,25,6); | Correct. | Perl |
DELETE FROM users WHERE name=48 | DELETE FROM users WHERE name=48; | Add semicolon. | SQL |
<br></br> | <br> | Self-closing. | HTML |
String c = 'test'; | String c = "test"; | Double quotes. | Java |
.User {{ color: #fff; }} | .User {{ color: #fff; }} | Correct. | CSS |
if result = 72 | if result == 72 | Use ==. | Go |
if b = 87 | if b == 87 | Use ==. | Ruby |
if [ $index = 50 ]; then | if [ "$index" = 50 ]; then | Quote variable. | Shell |
const user:Person = {{name:'result'}}; | const user:Person = {{name:'result', age:86}}; | Add missing property. | TypeScript |
function foo() {{
return
{{key:'message'}}
}} | function foo() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
[25, 63, 92 | [25, 63, 92] | Close bracket. | Ruby |
h1 {{ font-size:89px color:green; }} | h1 {{ font-size:89px; color:green; }} | Add semicolon. | CSS |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
fn bar() -> i32 {{ 71 }} | fn bar() -> i32 {{ 71 }} | Correct. | Rust |
for (int i=0; i<59; i++) {{}} | for (int i=0; i<59; i++) {{}} | Correct. | Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.