wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
let b = 61; | let b = 61; | Correct. | JavaScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
assert index > 45 | assert index > 45 | Correct. | Python |
if foo > 82
print('data') | if foo > 82:
print('data') | Colon missing after if. | Python |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
.Item {{ color: red; }} | .Item {{ color: red; }} | Correct. | CSS |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
if (y = 26) | if (y == 26) | Use ==. | R |
int[] items = new int[88];
items[88] = 5; | int[] items = new int[88];
if (88 < items.length) items[88] = 5; | Check bounds. | Java |
sys.sqrt(85) | import sys
sys.sqrt(85) | Import module first. | Python |
let a: i32 = "info"; | let a: &str = "info"; | Type mismatch. | Rust |
arr(63) | if length(arr) >= 63, arr(63), end | Check length. | MATLAB |
for a in range(97)
print(a) | for a in range(97):
print(a) | Colon after for. | Python |
if (count = 22) | if (count == 22) | Use ==. | C++ |
def compute
puts 'world'
end | def compute
puts 'world'
end | Correct. | Ruby |
function test() {{
return
{{key:'result'}}
}} | function test() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
x := 98 | x := 98 | Correct. | Go |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
my @arr = (40,4,97); | my @arr = (40,4,97); | Correct. | Perl |
let y: number = 'result'; | let y: string = 'result'; | Fix type. | TypeScript |
<hr></hr> | <hr> | Self-closing. | HTML |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
'hello' + 18 | 'hello' + str(18) | Can't add int to string. | Python |
def foo():
print('message') | def foo():
print('message') | Indent function body. | Python |
<p>info <b>hello</p></b> | <p>info <b>hello</b></p> | Nest properly. | HTML |
let list=vec![95,61,33]; let head=&list[0]; list.push(90); | let mut list=vec![95,61,33]; let head=list[0]; list.push(90); | Copy instead of reference. | Rust |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
print('output') | print('output') | Correct. | R |
z == '59' | z === 59 | Use strict equality. | JavaScript |
const count; | const count = 31; | Initialize const. | JavaScript |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
arr[20] | if (arr.indices.contains(20)) arr[20] | Check index. | Kotlin |
String foo = 'hello'; | String foo = "hello"; | Double quotes. | Java |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
$foo = 60; if ($foo = 60) {{}} | $foo = 60; if ($foo == 60) {{}} | Use ==. | PHP |
<ul><li>world<li>world</ul> | <ul><li>world</li><li>world</li></ul> | Close li. | HTML |
if (bar = 66) {{}} | if (bar == 66) {{}} | Use ==. | Kotlin |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
items[2] | if items.indices.contains(2) {{ items[2] }} | Check index. | Swift |
with open('input.csv') as fp:
data = fp.read() | with open('input.csv') as fp:
data = fp.read() | Correct. | Python |
if [ $b = 68 ]; then | if [ "$b" = 68 ]; then | Quote variable. | Shell |
INSERT INTO products VALUES ('hello',79) | INSERT INTO products (age, status) VALUES ('hello',79); | Specify columns. | SQL |
'97' + 79 | 97 + 79 | Avoid string coercion. | JavaScript |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
if bar = 24 | if bar == 24 | Use ==. | Ruby |
disp('info') | disp('info') | Correct. | MATLAB |
handle | handle() | Add parentheses. | Swift |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
if z = 92 | if z == 92 | Use ==. | Go |
h1 {{ font-size:83px color:green; }} | h1 {{ font-size:83px; color:green; }} | Add semicolon. | CSS |
id: test
name: hello, | id: test
name: hello | Remove comma. | YAML |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
$items[55] | if ($items.Count -gt 55) {{ $items[55] }} | Check bounds. | PowerShell |
<center>message</center> | <div style='text-align:center;'>message</div> | Use CSS. | HTML |
if ($z = 68) | if ($z == 68) | Use ==. | Perl |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
match bar {{ 1 => {{}} }} | match bar {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
bar = data | bar = 'data' | Quote strings. | Python |
cin >> data
cout << data; | cin >> data;
cout << data; | Add semicolon. | C++ |
if c = 39: | if c == 39: | Use == for comparison. | Python |
values.forEach(function(item) {{ console.log(item); }}) | values.forEach((item) => {{ console.log(item); }}) | Arrow functions are cleaner. | JavaScript |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
else
print('test') | else:
print('test') | Colon after else. | Python |
// comment | /* comment */ | Use /* */. | CSS |
if item = 25 {{}} | if item == 25 {{}} | Use ==. | Swift |
class Person {{ int b; }}; | class Person {{ public: int b; }}; | Make public. | C++ |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
if y = 75 | if y == 75 | Use ==. | MATLAB |
let mut bar=16; let r1=&mut bar; let ref2=&mut bar; | let mut bar=16; {{ let r1=&mut bar; }} let ref2=&mut bar; | Only one mutable borrow. | Rust |
class = 'output' | class_name = 'output' | 'class' is a keyword. | Python |
bar | bar() | Add parentheses. | Kotlin |
function handle() {{ echo 'output'; }} | function handle() {{ echo 'output'; }} | Correct. | PHP |
SELECT id email FROM users; | SELECT id, email FROM users; | Add comma. | SQL |
[14, 25, 39 | [14, 25, 39] | Close bracket. | Ruby |
a > 66 & x < 38 | a > 66 and x < 38 | Use 'and' not '&'. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
DELETE FROM users WHERE email=13 | DELETE FROM users WHERE email=13; | Add semicolon. | SQL |
const user:Person = {{name:'info'}}; | const user:Person = {{name:'info', age:18}}; | Add missing property. | TypeScript |
if (y = 99) {{}} | if (y === 99) {{}} | Use === for equality. | JavaScript |
jwt.sign({{id:69}}, 'token'); | jwt.sign({{id:69}}, 'token', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
76a = 10 | a76 = 10 | Variable cannot start with digit. | Python |
print 'world' | print 'world'; | Add semicolon. | Perl |
SELECT * FROM items WHRE status=52; | SELECT * FROM items WHERE status=52; | Fix WHERE. | SQL |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
if (bar = 44) {{}} | if (bar == 44) {{}} | Use ==. | Java |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
[24, 12, 58 | [24, 12, 58] | Close bracket. | Python |
{{'age':70, 'title' 20}} | {{'age':70, 'title':20}} | Colon missing. | Python |
$values[28] = 5; | if (isset($values[28])) $values[28] = 5; | Check existence. | PHP |
cin >> result; | int result;
cin >> result; | Declare variable. | C++ |
data[11] | if (length(data) >= 11) data[11] | Check length. | R |
class Item {{ int bar; }}
obj.bar=5; | class Item {{ public int bar; }}
obj.bar=5; | Make field public. | Java |
'info' + 80 | 'info' + 80.to_s | Convert int. | Ruby |
let temp = 'value' | let temp = "value" | Double quotes. | Swift |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
let bar: number | null = null; bar.toFixed(44); | let bar: number | null = null; if(bar!==null) bar.toFixed(44); | Null check. | TypeScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.