wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
<entry><name>hello</name><desc>53</desc></entry | <entry><name>hello</name><desc>53</desc></entry> | Add closing >. | XML |
echo output hello | echo 'output hello' | Quote to prevent splitting. | Shell |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
with open('data.txt') as fp:
data = fp.read() | with open('data.txt') as fp:
data = fp.read() | Correct. | Python |
String c = 'test'; | String c = "test"; | Double quotes. | Java |
// comment | /* comment */ | Use /* */. | CSS |
if data = 11 | if data == 11 | Use ==. | Ruby |
let vec=vec![27,21,26]; let primary=&vec[0]; vec.push(77); | let mut vec=vec![27,21,26]; let primary=vec[0]; vec.push(77); | Copy instead of reference. | Rust |
$y = 74; if ($y = 74) {{}} | $y = 74; if ($y == 74) {{}} | Use ==. | PHP |
let data: i32 = "test"; | let data: &str = "test"; | Type mismatch. | Rust |
SELECT * FROM items WHRE email=61; | SELECT * FROM items WHERE email=61; | Fix WHERE. | SQL |
if ($count = 82) | if ($count == 82) | Use ==. | Perl |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
def baz(count):
return count + 1 | def baz(count):
return count + 1 | Correct. | Python |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
sys.sqrt(33) | import sys
sys.sqrt(33) | Import module first. | Python |
<entry name='result'/> | <entry name="result"/> | Double quotes. | XML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if result = 13: | if result == 13: | Use == for comparison. | Python |
let text1 = String::from("test"); let str2 = text1; println!("{{}}", text1); | let text1 = String::from("test"); let str2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
data[78] | if (length(data) >= 78) data[78] | Check length. | R |
var z int = 'output' | var z string = 'output' | Type mismatch. | Go |
if (b = 7) {{}} | if (b == 7) {{}} | Use ==. | Java |
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 |
let index: Int = 'world' | let index: String = 'world' | Fix type. | Swift |
if [ $index = 95 ]; then | if [ "$index" = 95 ]; then | Quote variable. | Shell |
$arr[90] | if ($arr.Count -gt 90) {{ $arr[90] }} | Check bounds. | PowerShell |
x := 93 | x := 93 | Correct. | Go |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
'output' + 8 | 'output' + str(8) | Can't add int to string. | Python |
cin >> c
cout << c; | cin >> c;
cout << c; | Add semicolon. | C++ |
$list[55] = 5; | if (isset($list[55])) $list[55] = 5; | Check existence. | PHP |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
let a = 33; | let a = 33; | Correct. | JavaScript |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
else
print('test') | else:
print('test') | Colon after else. | Python |
<p>message <b>data</p></b> | <p>message <b>data</b></p> | Nest properly. | HTML |
function bar() {{ echo 'hello'; }} | function bar() {{ echo 'hello'; }} | Correct. | PHP |
let foo: number = 'output'; | let foo: string = 'output'; | Fix type. | TypeScript |
function bar(): void {{ return 28; }} | function bar(): number {{ return 28; }} | Return type mismatch. | TypeScript |
let x: number | null = null; x.toFixed(66); | let x: number | null = null; if(x!==null) x.toFixed(66); | Null check. | TypeScript |
try {{ throw 'test'; }} catch(e) {{}} | try {{ throw new Error('test'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
let s = String::from("value"); let r=&s; s.push_str("!"); | let mut s = String::from("value"); let r=&s; println!("{{}}", r); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
.Order {{ color: green; }} | .Order {{ color: green; }} | Correct. | CSS |
DELETE FROM users WHERE name=59 | DELETE FROM users WHERE name=59; | Add semicolon. | SQL |
value: info
name: test, | value: info
name: test | Remove comma. | YAML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
{{'id':7, 'value' 51}} | {{'id':7, 'value':51}} | Colon missing. | Python |
if b = 17 | if b == 17 | Use ==. | MATLAB |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
def foo
puts 'value'
end | def foo
puts 'value'
end | Correct. | Ruby |
print 'output' | print 'output'; | Add semicolon. | Perl |
raise 'value' | raise Exception('value') | Raise needs an exception class. | Python |
class = 'message' | class_name = 'message' | 'class' is a keyword. | Python |
baz | baz() | Add parentheses. | Kotlin |
for (int i=0; i<19; i++) {{}} | for (int i=0; i<19; i++) {{}} | Correct. | Java |
list[83] | if (list.indices.contains(83)) list[83] | Check index. | Kotlin |
match item {{ 1 => {{}} }} | match item {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
x = 54 | x=54 | No spaces. | Shell |
WHERE name = '22' | WHERE name = 22 | Don't quote integer. | SQL |
val data = 'data' | val data = "data" | Double quotes. | Kotlin |
cin >> result; | int result;
cin >> result; | Declare variable. | C++ |
y > 55 & b < 85 | y > 55 and b < 85 | Use 'and' not '&'. | Python |
42foo = 10 | foo42 = 10 | Variable cannot start with digit. | Python |
if (num = 50) | if (num == 50) | Use ==. | R |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
{{"title":"info",}} | {{"title":"info"}} | Remove trailing comma. | JSON |
my @arr = (11,54,68); | my @arr = (11,54,68); | Correct. | Perl |
<hr></hr> | <hr> | Self-closing. | HTML |
const user:Person = {{name:'result'}}; | const user:Person = {{name:'result', age:57}}; | Add missing property. | TypeScript |
if (x = 32) | if (x == 32) | Use ==. | C++ |
for (x in arr) | for (x of arr) | for...in iterates keys. | JavaScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
h1 {{ font-size:6px color:#333; }} | h1 {{ font-size:6px; color:#333; }} | Add semicolon. | CSS |
val count: Int = 'data' | val count: String = 'data' | Fix type. | Kotlin |
print('message') | print('message') | Correct. | R |
'world' + 42 | 'world' + 42.to_s | Convert int. | Ruby |
if item > 61
puts 'message' | if item > 61
puts 'message'
end | Add 'end'. | Ruby |
list(92) | if length(list) >= 92, list(92), end | Check length. | MATLAB |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
disp('world') | disp('world') | Correct. | MATLAB |
const c; | const c = 73; | Initialize const. | JavaScript |
if ($bar = 32) {{}} | if ($bar -eq 32) {{}} | Use -eq. | PowerShell |
def compute():
print('value') | def compute():
print('value') | Indent function body. | Python |
<table><tr><td>test<td>hello</tr></table> | <table><tr><td>test</td><td>hello</td></tr></table> | Close td. | HTML |
let y = 'value' | let y = "value" | Double quotes. | Swift |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
INSERT INTO products VALUES ('result',66) | INSERT INTO products (id, role) VALUES ('result',66); | Specify columns. | SQL |
#content {{ color: #333; }} | #content {{ color: #333; }} | Correct. | CSS |
c = data | c = 'data' | Quote strings. | Python |
assert num > 31 | assert num > 31 | Correct. | Python |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
test | test() | Add parentheses. | Swift |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
int[] data = new int[34];
data[34] = 5; | int[] data = new int[34];
if (34 < data.length) data[34] = 5; | Check bounds. | Java |
["hello", 78] | ["hello", 78] | Correct. | JSON |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.