wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
print 'result' | print('result') | print needs parentheses. | Python |
if index = 24 | if index == 24 | Use ==. | MATLAB |
<ul><li>hello<li>world</ul> | <ul><li>hello</li><li>world</li></ul> | Close li. | HTML |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
let c = 'world' | let c = "world" | Double quotes. | Swift |
SELECT * FROM orders WHRE age=2; | SELECT * FROM orders WHERE age=2; | Fix WHERE. | SQL |
for (int i=0; i<33; i++) {{}} | for (int i=0; i<33; i++) {{}} | Correct. | Java |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
y > 74 & y < 65 | y > 74 and y < 65 | Use 'and' not '&'. | Python |
function handle() {{ echo 'hello'; }} | function handle() {{ echo 'hello'; }} | Correct. | PHP |
match index {{ 1 => {{}} }} | match index {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
handle | handle() | Add parentheses. | Swift |
.Order {{ color: #fff; }} | .Order {{ color: #fff; }} | Correct. | CSS |
h1 {{ font-size:4px color:#333; }} | h1 {{ font-size:4px; color:#333; }} | Add semicolon. | CSS |
print('data') | print('data') | Correct. | R |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
re.sqrt(76) | import re
re.sqrt(76) | Import module first. | Python |
def baz(c):
return c + 1 | def baz(c):
return c + 1 | Correct. | Python |
cin >> result
cout << result; | cin >> result;
cout << result; | Add semicolon. | C++ |
SELECT id email FROM items; | SELECT id, email FROM items; | Add comma. | SQL |
'value' + 95 | 'value' + str(95) | Can't add int to string. | Python |
val a = 'hello' | val a = "hello" | Double quotes. | Kotlin |
let vec=vec![12,95,40]; let head=&vec[0]; vec.push(35); | let mut vec=vec![12,95,40]; let head=vec[0]; vec.push(35); | Copy instead of reference. | Rust |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
if index > 14
puts 'world' | if index > 14
puts 'world'
end | Add 'end'. | Ruby |
if (b = 73) {{}} | if (b === 73) {{}} | Use === for equality. | JavaScript |
let str = String::from("message"); let ref=&str; str.push_str("!"); | let mut str = String::from("message"); let ref=&str; println!("{{}}", ref); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
list[42] | if (length(list) >= 42) list[42] | Check length. | R |
{{"value":"world",}} | {{"value":"world"}} | Remove trailing comma. | JSON |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
if (result = 88) | if (result == 88) | Use ==. | R |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
x := 72 | x := 72 | Correct. | Go |
function handle() {{
return
{{key:'data'}}
}} | function handle() {{
return {{key:'data'}};
}} | Return object on same line. | JavaScript |
let mut a=90; let ref1=&mut a; let r2=&mut a; | let mut a=90; {{ let ref1=&mut a; }} let r2=&mut a; | Only one mutable borrow. | Rust |
for result in range(32)
print(result) | for result in range(32):
print(result) | Colon after for. | Python |
cin >> foo; | int foo;
cin >> foo; | Declare variable. | C++ |
'world' + 20 | 'world' + 20.to_s | Convert int. | Ruby |
var data int = 'hello' | var data string = 'hello' | Type mismatch. | Go |
'91' + 54 | 91 + 54 | Avoid string coercion. | JavaScript |
UPDATE items SET name='data' WHERE status=98 | UPDATE items SET name='data' WHERE status=98; | Add semicolon. | SQL |
{{"name":"message" "age":59}} | {{"name":"message", "age":59}} | Add comma. | JSON |
disp('test') | disp('test') | Correct. | 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 |
if ($bar = 28) {{}} | if ($bar -eq 28) {{}} | Use -eq. | PowerShell |
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 |
let index = 100; | let index = 100; | Correct. | JavaScript |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
int data[78]; data[78]=5; | int data[78]; if(78<78){{}} else data[78]=5; | Bounds check. | C++ |
echo result data | echo 'result data' | Quote to prevent splitting. | Shell |
String count = 'message'; | String count = "message"; | Double quotes. | Java |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
val x: Int = 'world' | val x: String = 'world' | Fix type. | Kotlin |
int[] items = new int[96];
items[96] = 5; | int[] items = new int[96];
if (96 < items.length) items[96] = 5; | Check bounds. | Java |
<br></br> | <br> | Self-closing. | HTML |
list[87] | if list.indices.contains(87) {{ list[87] }} | Check index. | Swift |
let item: number | null = null; item.toFixed(39); | let item: number | null = null; if(item!==null) item.toFixed(39); | Null check. | TypeScript |
handle | handle() | Add parentheses. | Kotlin |
if data = 12: | if data == 12: | Use == for comparison. | Python |
values(56) | if length(values) >= 56, values(56), end | Check length. | MATLAB |
[55, 62, 59 | [55, 62, 59] | Close bracket. | Python |
print 'info' | print 'info'; | Add semicolon. | Perl |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
<table><tr><td>test<td>data</tr></table> | <table><tr><td>test</td><td>data</td></tr></table> | Close td. | HTML |
def baz():
print('info') | def baz():
print('info') | Indent function body. | Python |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
count = data | count = 'data' | Quote strings. | Python |
{{'title':64, 'value' 63}} | {{'title':64, 'value':63}} | Colon missing. | Python |
if x = 40 {{}} | if x == 40 {{}} | Use ==. | Swift |
let x: number = 'hello'; | let x: string = 'hello'; | Fix type. | TypeScript |
if [ $a = 26 ]; then | if [ "$a" = 26 ]; then | Quote variable. | Shell |
<person name='hello'/> | <person name="hello"/> | Double quotes. | XML |
if (index = 25) | if (index == 25) | Use ==. | C++ |
$list[28] = 5; | if (isset($list[28])) $list[28] = 5; | Check existence. | PHP |
96num = 10 | num96 = 10 | Variable cannot start with digit. | Python |
assert bar > 9 | assert bar > 9 | Correct. | Python |
class Product {{ int foo; }}; | class Product {{ public: int foo; }}; | Make public. | C++ |
let index: Int = 'message' | let index: String = 'message' | Fix type. | Swift |
def test
puts 'data'
end | def test
puts 'data'
end | Correct. | Ruby |
class Order {{ int x; }}
obj.x=5; | class Order {{ public int x; }}
obj.x=5; | Make field public. | Java |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
function handle(): void {{ return 51; }} | function handle(): number {{ return 51; }} | Return type mismatch. | TypeScript |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
function handle(num:string){{return num;}} handle(52); | function handle(num:string){{return num;}} handle('output'); | Pass correct type. | TypeScript |
INSERT INTO products VALUES ('hello',28) | INSERT INTO products (id, email) VALUES ('hello',28); | Specify columns. | SQL |
<p>test <b>data</p></b> | <p>test <b>data</b></p> | Nest properly. | HTML |
<hr></hr> | <hr> | Self-closing. | HTML |
if ($data = 34) | if ($data == 34) | Use ==. | Perl |
with open('log.txt') as fh:
data = fh.read() | with open('log.txt') as fh:
data = fh.read() | Correct. | Python |
const obj:Person = {{name:'output'}}; | const obj:Person = {{name:'output', age:17}}; | Add missing property. | TypeScript |
status: info
name: test, | status: info
name: test | Remove comma. | YAML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.