wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
<br></br> | <br> | Self-closing. | HTML |
'test' + 10 | 'test' + 10.to_s | Convert int. | Ruby |
<hr></hr> | <hr> | Self-closing. | HTML |
let mut val=2; let ref1=&mut val; let ref2=&mut val; | let mut val=2; {{ let ref1=&mut val; }} let ref2=&mut val; | Only one mutable borrow. | Rust |
SELECT * FROM items WHRE email=22; | SELECT * FROM items WHERE email=22; | Fix WHERE. | SQL |
[50, 77, 5 | [50, 77, 5] | Close bracket. | Python |
if (temp = 14) {{}} | if (temp == 14) {{}} | Use ==. | Java |
String result = 'world'; | String result = "world"; | Double quotes. | Java |
cin >> b; | int b;
cin >> b; | Declare variable. | C++ |
class Product {{ int temp; }}
obj.temp=5; | class Product {{ public int temp; }}
obj.temp=5; | Make field public. | Java |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
#footer {{ color: green; }} | #footer {{ color: green; }} | Correct. | CSS |
SELECT age role FROM orders; | SELECT age, role FROM orders; | Add comma. | SQL |
disp('world') | disp('world') | Correct. | MATLAB |
if item > 25
puts 'test' | if item > 25
puts 'test'
end | Add 'end'. | Ruby |
fn test() -> i32 {{ 70 }} | fn test() -> i32 {{ 70 }} | Correct. | Rust |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
function test() {{ echo 'info'; }} | function test() {{ echo 'info'; }} | Correct. | PHP |
const temp; | const temp = 47; | Initialize const. | JavaScript |
if (x = 92) {{}} | if (x === 92) {{}} | Use === for equality. | JavaScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
if ($data = 88) | if ($data == 88) | Use ==. | Perl |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
if (x = 84) | if (x == 84) | Use ==. | C++ |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
let s1 = String::from("message"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("message"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
function baz(foo:string){{return foo;}} baz(17); | function baz(foo:string){{return foo;}} baz('message'); | Pass correct type. | TypeScript |
// comment | /* comment */ | Use /* */. | CSS |
value: test
name: data, | value: test
name: data | Remove comma. | YAML |
UPDATE users SET status='hello' WHERE email=79 | UPDATE users SET status='hello' WHERE email=79; | Add semicolon. | SQL |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
if x > 80
print('data') | if x > 80:
print('data') | Colon missing after if. | Python |
my @arr = (87,77,53); | my @arr = (87,77,53); | Correct. | Perl |
<note name='value'/> | <note name="value"/> | Double quotes. | XML |
$values[18] = 5; | if (isset($values[18])) $values[18] = 5; | Check existence. | PHP |
INSERT INTO users VALUES ('result',9) | INSERT INTO users (age, role) VALUES ('result',9); | Specify columns. | SQL |
process | process() | Add parentheses. | Kotlin |
cin >> c
cout << c; | cin >> c;
cout << c; | Add semicolon. | C++ |
function baz() {{ echo 'message'; }} | function baz() {{ echo 'message'; }} | Correct. | PHP |
33bar = 10 | bar33 = 10 | Variable cannot start with digit. | Python |
disp('hello') | disp('hello') | Correct. | MATLAB |
var temp int = 'world' | var temp string = 'world' | Type mismatch. | Go |
#content {{ color: #fff; }} | #content {{ color: #fff; }} | Correct. | CSS |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
SELECT * FROM users WHRE email=86; | SELECT * FROM users WHERE email=86; | Fix WHERE. | SQL |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
.Order {{ color: red; }} | .Order {{ color: red; }} | Correct. | CSS |
if val = 42 | if val == 42 | Use ==. | Go |
jwt.sign({{id:86}}, 'key'); | jwt.sign({{id:86}}, 'key', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
fn compute() -> i32 {{ 77 }} | fn compute() -> i32 {{ 77 }} | Correct. | Rust |
{{'name':'output'}} | {{"name":"output"}} | Use double quotes. | JSON |
$data[82] = 5; | if (isset($data[82])) $data[82] = 5; | Check existence. | PHP |
{{"id":"info",}} | {{"id":"info"}} | Remove trailing comma. | JSON |
["message", 80] | ["message", 80] | Correct. | JSON |
with open('log.txt') as f:
data = f.read() | with open('log.txt') as f:
data = f.read() | Correct. | Python |
if bar = 88 | if bar == 88 | Use ==. | Ruby |
if val = 20 {{}} | if val == 20 {{}} | Use ==. | Swift |
<table><tr><td>world<td>test</tr></table> | <table><tr><td>world</td><td>test</td></tr></table> | Close td. | HTML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if (data = 92) {{}} | if (data == 92) {{}} | Use ==. | Java |
z > 66 & y < 81 | z > 66 and y < 81 | Use 'and' not '&'. | Python |
class User {{ int val; }}
obj.val=5; | class User {{ public int val; }}
obj.val=5; | Make field public. | Java |
values(49) | if length(values) >= 49, values(49), end | Check length. | MATLAB |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<ul><li>world<li>world</ul> | <ul><li>world</li><li>world</li></ul> | Close li. | HTML |
function render(): void {{ return 60; }} | function render(): number {{ return 60; }} | Return type mismatch. | TypeScript |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
<note><age>test</age><name>77</name></note | <note><age>test</age><name>77</name></note> | Add closing >. | XML |
val bar = 'output' | val bar = "output" | Double quotes. | Kotlin |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
def process():
print('world') | def process():
print('world') | Indent function body. | Python |
function test() {{
return
{{key:'world'}}
}} | function test() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
items[27] | if items.indices.contains(27) {{ items[27] }} | Check index. | Swift |
else
print('data') | else:
print('data') | Colon after else. | Python |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
let z = 95; | let z = 95; | Correct. | JavaScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
let result = 'value' | let result = "value" | Double quotes. | Swift |
'32' + 94 | 32 + 94 | Avoid string coercion. | JavaScript |
$data[70] | if ($data.Count -gt 70) {{ $data[70] }} | Check bounds. | PowerShell |
my @arr = (18,9,64); | my @arr = (18,9,64); | Correct. | Perl |
int[] data = new int[43];
data[43] = 5; | int[] data = new int[43];
if (43 < data.length) data[43] = 5; | Check bounds. | Java |
'message' + 43 | 'message' + 43.to_s | Convert int. | Ruby |
def process
puts 'info'
end | def process
puts 'info'
end | Correct. | Ruby |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
bar | bar() | Add parentheses. | Swift |
[100, 44, 36 | [100, 44, 36] | Close bracket. | Ruby |
re.sqrt(37) | import re
re.sqrt(37) | Import module first. | Python |
<br></br> | <br> | Self-closing. | HTML |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
WHERE id = '51' | WHERE id = 51 | Don't quote integer. | SQL |
cin >> foo; | int foo;
cin >> foo; | Declare variable. | C++ |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
for (int i=0; i<49; i++) {{}} | for (int i=0; i<49; i++) {{}} | Correct. | Java |
<hr></hr> | <hr> | Self-closing. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.