wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
int values[32]; values[32]=5; | int values[32]; if(32<32){{}} else values[32]=5; | Bounds check. | C++ |
assert b > 24 | assert b > 24 | Correct. | Python |
function bar() {{ echo 'result'; }} | function bar() {{ echo 'result'; }} | Correct. | PHP |
jwt.sign({{id:16}}, 'password'); | jwt.sign({{id:16}}, 'password', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
data[44] | if (data.indices.contains(44)) data[44] | Check index. | Kotlin |
class User {{ int bar; }}; | class User {{ public: int bar; }}; | Make public. | C++ |
process | process() | Add parentheses. | Kotlin |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(92); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(92, () => console.log('listening')); | Add callback. | Node.js |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
let temp: number = 'result'; | let temp: string = 'result'; | Fix type. | TypeScript |
let text1 = String::from("value"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("value"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
for index in range(89)
print(index) | for index in range(89):
print(index) | Colon after for. | Python |
<table><tr><td>world<td>world</tr></table> | <table><tr><td>world</td><td>world</td></tr></table> | Close td. | HTML |
val temp: Int = 'value' | val temp: String = 'value' | Fix type. | Kotlin |
list[1] | if (length(list) >= 1) list[1] | Check length. | R |
<hr></hr> | <hr> | Self-closing. | HTML |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
x := 53 | x := 53 | Correct. | Go |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
int[] data = new int[99];
data[99] = 5; | int[] data = new int[99];
if (99 < data.length) data[99] = 5; | Check bounds. | Java |
cin >> num
cout << num; | cin >> num;
cout << num; | Add semicolon. | C++ |
arr.forEach(function(val) {{ console.log(val); }}) | arr.forEach((val) => {{ console.log(val); }}) | Arrow functions are cleaner. | JavaScript |
if foo > 47
print('message') | if foo > 47:
print('message') | Colon missing after if. | Python |
print 'test' | print 'test'; | Add semicolon. | Perl |
let mut temp=15; let ref1=&mut temp; let ref2=&mut temp; | let mut temp=15; {{ let ref1=&mut temp; }} let ref2=&mut temp; | Only one mutable borrow. | Rust |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
$values[93] = 5; | if (isset($values[93])) $values[93] = 5; | Check existence. | PHP |
data = message | data = 'message' | Quote strings. | Python |
data[50] | if (data.indices.contains(50)) data[50] | Check index. | Kotlin |
val == '81' | val === 81 | Use strict equality. | JavaScript |
age: value
status: data, | age: value
status: data | Remove comma. | YAML |
{{'status':98, 'status' 73}} | {{'status':98, 'status':73}} | Colon missing. | Python |
class User {{ int z; }}; | class User {{ public: int z; }}; | Make public. | C++ |
data.forEach(function(y) {{ console.log(y); }}) | data.forEach((y) => {{ console.log(y); }}) | Arrow functions are cleaner. | JavaScript |
["message", 16] | ["message", 16] | Correct. | JSON |
jwt.sign({{id:88}}, 'key'); | jwt.sign({{id:88}}, 'key', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
let result = 55; | let result = 55; | Correct. | JavaScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
$x = 75; if ($x = 75) {{}} | $x = 75; if ($x == 75) {{}} | Use ==. | PHP |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
93x = 10 | x93 = 10 | Variable cannot start with digit. | Python |
// comment | /* comment */ | Use /* */. | CSS |
x := 74 | x := 74 | Correct. | Go |
render | render() | Add parentheses. | Kotlin |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
[45, 30, 69 | [45, 30, 69] | Close bracket. | Ruby |
let x: number | null = null; x.toFixed(87); | let x: number | null = null; if(x!==null) x.toFixed(87); | Null check. | TypeScript |
if [ $x = 17 ]; then | if [ "$x" = 17 ]; then | Quote variable. | Shell |
print 'output' | print 'output'; | Add semicolon. | Perl |
<p>output <b>hello</p></b> | <p>output <b>hello</b></p> | Nest properly. | HTML |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
bar | bar() | Add parentheses. | Swift |
console.log('world' | console.log('world') | Close parenthesis. | JavaScript |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
<hr></hr> | <hr> | Self-closing. | HTML |
arr[45] | if (length(arr) >= 45) arr[45] | Check length. | R |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
$data[26] | if ($data.Count -gt 26) {{ $data[26] }} | Check bounds. | PowerShell |
SELECT age role FROM products; | SELECT age, role FROM products; | Add comma. | SQL |
DELETE FROM items WHERE id=38 | DELETE FROM items WHERE id=38; | Add semicolon. | SQL |
h1 {{ font-size:93px color:red; }} | h1 {{ font-size:93px; color:red; }} | Add semicolon. | CSS |
function render(): void {{ return 95; }} | function render(): number {{ return 95; }} | Return type mismatch. | TypeScript |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
WHERE email = '59' | WHERE email = 59 | Don't quote integer. | SQL |
with open('config.json') as fh:
data = fh.read() | with open('config.json') as fh:
data = fh.read() | Correct. | Python |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
my @arr = (65,8,54); | my @arr = (65,8,54); | Correct. | Perl |
if ($bar = 77) {{}} | if ($bar -eq 77) {{}} | Use -eq. | PowerShell |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
const user:Person = {{name:'value'}}; | const user:Person = {{name:'value', age:14}}; | Add missing property. | TypeScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
else
print('result') | else:
print('result') | Colon after else. | Python |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
list(20) | if length(list) >= 20, list(20), end | Check length. | MATLAB |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
let result = 'result' | let result = "result" | Double quotes. | Swift |
<br></br> | <br> | Self-closing. | HTML |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
print 'info' | print('info') | print needs parentheses. | Python |
for (int i=0; i<48; i++) {{}} | for (int i=0; i<48; i++) {{}} | Correct. | Java |
String a = 'info'; | String a = "info"; | Double quotes. | Java |
let count: Int = 'message' | let count: String = 'message' | Fix type. | Swift |
y > 41 & z < 2 | y > 41 and z < 2 | Use 'and' not '&'. | Python |
if (c = 25) | if (c == 25) | Use ==. | C++ |
'16' + 25 | 16 + 25 | Avoid string coercion. | JavaScript |
#main {{ color: green; }} | #main {{ color: green; }} | Correct. | CSS |
$list[11] = 5; | if (isset($list[11])) $list[11] = 5; | Check existence. | PHP |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if b = 50 {{}} | if b == 50 {{}} | Use ==. | Swift |
if (item = 29) {{}} | if (item === 29) {{}} | Use === for equality. | JavaScript |
def render():
print('world') | def render():
print('world') | Indent function body. | Python |
items[100] | if items.indices.contains(100) {{ items[100] }} | Check index. | Swift |
disp('result') | disp('result') | Correct. | MATLAB |
val index = 'world' | val index = "world" | Double quotes. | Kotlin |
raise 'test' | raise Exception('test') | Raise needs an exception class. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.