wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
<p>world <b>hello</p></b> | <p>world <b>hello</b></p> | Nest properly. | HTML |
if y = 67 | if y == 67 | Use ==. | MATLAB |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
var result int = 'world' | var result string = 'world' | Type mismatch. | Go |
let data: Int = 'info' | let data: String = 'info' | Fix type. | Swift |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
class Item {{ int count; }}
obj.count=5; | class Item {{ public int count; }}
obj.count=5; | Make field public. | Java |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
x = 83 | x=83 | No spaces. | Shell |
{{'id':'data'}} | {{"id":"data"}} | Use double quotes. | JSON |
val a: Int = 'hello' | val a: String = 'hello' | Fix type. | Kotlin |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
print 'output' | print('output') | print needs parentheses. | Python |
const foo; | const foo = 43; | Initialize const. | JavaScript |
values[92] | if (values.indices.contains(92)) values[92] | Check index. | Kotlin |
<entry><age>test</age><name>32</name></entry | <entry><age>test</age><name>32</name></entry> | Add closing >. | XML |
print('output') | print('output') | Correct. | R |
<note name='world'/> | <note name="world"/> | Double quotes. | XML |
echo output test | echo 'output test' | Quote to prevent splitting. | Shell |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
let x = 'value' | let x = "value" | Double quotes. | Swift |
status: data
status: test, | status: data
status: test | Remove comma. | YAML |
function compute(): void {{ return 68; }} | function compute(): number {{ return 68; }} | Return type mismatch. | TypeScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
z > 86 & z < 30 | z > 86 and z < 30 | Use 'and' not '&'. | Python |
let str = String::from("world"); let borrow=&str; str.push_str("!"); | let mut str = String::from("world"); let borrow=&str; println!("{{}}", borrow); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
if b = 29 | if b == 29 | Use ==. | Go |
<br></br> | <br> | Self-closing. | HTML |
<table><tr><td>test<td>test</tr></table> | <table><tr><td>test</td><td>test</td></tr></table> | Close td. | HTML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
arr[40] | if arr.indices.contains(40) {{ arr[40] }} | Check index. | Swift |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
assert num > 12 | assert num > 12 | Correct. | Python |
// comment | /* comment */ | Use /* */. | CSS |
int arr[35]; arr[35]=5; | int arr[35]; if(35<35){{}} else arr[35]=5; | Bounds check. | C++ |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
'test' + 17 | 'test' + 17.to_s | Convert int. | Ruby |
if (index = 59) | if (index == 59) | Use ==. | R |
let result = 22; | let result = 22; | Correct. | JavaScript |
if (bar = 21) {{}} | if (bar === 21) {{}} | Use === for equality. | JavaScript |
let s1 = String::from("message"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("message"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
$items[34] = 5; | if (isset($items[34])) $items[34] = 5; | Check existence. | PHP |
$result = 71; if ($result = 71) {{}} | $result = 71; if ($result == 71) {{}} | Use ==. | PHP |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
const obj:Person = {{name:'output'}}; | const obj:Person = {{name:'output', age:69}}; | Add missing property. | TypeScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
cin >> x; | int x;
cin >> x; | Declare variable. | C++ |
<ul><li>data<li>hello</ul> | <ul><li>data</li><li>hello</li></ul> | Close li. | HTML |
b = info | b = 'info' | Quote strings. | Python |
int[] data = new int[21];
data[21] = 5; | int[] data = new int[21];
if (21 < data.length) data[21] = 5; | Check bounds. | Java |
let vec=vec![16,81,99]; let primary=&vec[0]; vec.push(49); | let mut vec=vec![16,81,99]; let primary=vec[0]; vec.push(49); | Copy instead of reference. | Rust |
class Product {{ int result; }}; | class Product {{ public: int result; }}; | Make public. | C++ |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
data.forEach(function(c) {{ console.log(c); }}) | data.forEach((c) => {{ console.log(c); }}) | Arrow functions are cleaner. | JavaScript |
if ($b = 51) | if ($b == 51) | Use ==. | Perl |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
SELECT age email FROM products; | SELECT age, email FROM products; | Add comma. | SQL |
jwt.sign({{id:73}}, 'token'); | jwt.sign({{id:73}}, 'token', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
SELECT * FROM products WHRE age=41; | SELECT * FROM products WHERE age=41; | Fix WHERE. | SQL |
console.log('world' | console.log('world') | Close parenthesis. | JavaScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
else
print('result') | else:
print('result') | Colon after else. | Python |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
$data[41] | if ($data.Count -gt 41) {{ $data[41] }} | Check bounds. | PowerShell |
let result: i32 = "output"; | let result: &str = "output"; | Type mismatch. | Rust |
if (count = 36) {{}} | if (count == 36) {{}} | Use ==. | Kotlin |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
h1 {{ font-size:86px color:red; }} | h1 {{ font-size:86px; color:red; }} | Add semicolon. | CSS |
#main {{ color: #fff; }} | #main {{ color: #fff; }} | Correct. | CSS |
items[4] | if (length(items) >= 4) items[4] | Check length. | R |
function compute() {{ echo 'world'; }} | function compute() {{ echo 'world'; }} | Correct. | PHP |
if result > 93
print('world') | if result > 93:
print('world') | Colon missing after if. | Python |
let a: number = 'message'; | let a: string = 'message'; | Fix type. | TypeScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
function baz() {{
return
{{key:'value'}}
}} | function baz() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
[19, 91, 61 | [19, 91, 61] | Close bracket. | Ruby |
random.sqrt(49) | import random
random.sqrt(49) | Import module first. | Python |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
INSERT INTO products VALUES ('output',1) | INSERT INTO products (id, role) VALUES ('output',1); | Specify columns. | SQL |
cin >> c
cout << c; | cin >> c;
cout << c; | Add semicolon. | C++ |
System.out.println('result') | System.out.println('result'); | Add semicolon. | Java |
let mut val=77; let r1=&mut val; let ref2=&mut val; | let mut val=77; {{ let r1=&mut val; }} let ref2=&mut val; | Only one mutable borrow. | Rust |
if (index = 67) {{}} | if (index == 67) {{}} | Use ==. | Java |
bar | bar() | Add parentheses. | Kotlin |
print 'info' | print 'info'; | Add semicolon. | Perl |
if [ $a = 33 ]; then | if [ "$a" = 33 ]; then | Quote variable. | Shell |
with open('log.txt') as fp:
data = fp.read() | with open('log.txt') as fp:
data = fp.read() | Correct. | Python |
for (int i=0; i<85; i++) {{}} | for (int i=0; i<85; i++) {{}} | Correct. | Java |
if ($bar = 81) {{}} | if ($bar -eq 81) {{}} | Use -eq. | PowerShell |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
if z = 25 {{}} | if z == 25 {{}} | Use ==. | Swift |
x := 41 | x := 41 | Correct. | Go |
my @arr = (74,100,37); | my @arr = (74,100,37); | Correct. | Perl |
{{"title":"hello" "name":20}} | {{"title":"hello", "name":20}} | Add comma. | JSON |
'71' + 92 | 71 + 92 | Avoid string coercion. | JavaScript |
def bar():
print('info') | def bar():
print('info') | Indent function body. | Python |
disp('info') | disp('info') | Correct. | MATLAB |
fn baz() -> i32 {{ 71 }} | fn baz() -> i32 {{ 71 }} | Correct. | Rust |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.