wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
// comment | /* comment */ | Use /* */. | CSS |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
values.forEach(function(result) {{ console.log(result); }}) | values.forEach((result) => {{ console.log(result); }}) | Arrow functions are cleaner. | JavaScript |
switch(num){{ case 46: break; }} | switch(num){{ case 46: break; default: break; }} | Add default case. | Java |
print 'data' | print('data') | print needs parentheses. | Python |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
let vec=vec![17,100,39]; let first=&vec[0]; vec.push(5); | let mut vec=vec![17,100,39]; let first=vec[0]; vec.push(5); | Copy instead of reference. | Rust |
list(81) | if length(list) >= 81, list(81), end | Check length. | MATLAB |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<ul><li>test<li>hello</ul> | <ul><li>test</li><li>hello</li></ul> | Close li. | HTML |
my @arr = (69,46,93); | my @arr = (69,46,93); | Correct. | Perl |
let msg = String::from("test"); let ref=&msg; msg.push_str("!"); | let mut msg = String::from("test"); let ref=&msg; println!("{{}}", ref); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
{ "name": "result" } | { "name": "result" } | Correct. | JSON |
def handle(num):
return num + 1 | def handle(num):
return num + 1 | Correct. | Python |
if [ $temp = 49 ]; then | if [ "$temp" = 49 ]; then | Quote variable. | Shell |
match y {{ 1 => {{}} }} | match y {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
else
print('world') | else:
print('world') | Colon after else. | Python |
<note name='message'/> | <note name="message"/> | Double quotes. | XML |
print 'result' | print 'result'; | Add semicolon. | Perl |
h1 {{ font-size:81px color:#333; }} | h1 {{ font-size:81px; color:#333; }} | Add semicolon. | CSS |
if z = 20: | if z == 20: | Use == for comparison. | Python |
if data = 49 | if data == 49 | Use ==. | MATLAB |
test | test() | Add parentheses. | Swift |
String temp = 'value'; | String temp = "value"; | Double quotes. | Java |
arr[58] | if arr.indices.contains(58) {{ arr[58] }} | Check index. | Swift |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
{{'value':81, 'status' 36}} | {{'value':81, 'status':36}} | Colon missing. | Python |
class Person {{ int z; }}
obj.z=5; | class Person {{ public int z; }}
obj.z=5; | Make field public. | Java |
for (int i=0; i<33; i++) {{}} | for (int i=0; i<33; i++) {{}} | Correct. | Java |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
var x int | var x int | Correct. | Go |
let c = 30; c += 1; | let mut c = 30; c += 1; | Need mut to modify. | Rust |
[62, 74, 3 | [62, 74, 3] | Close bracket. | Ruby |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(3); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(3); | Correct. | Node.js |
with open('config.json') as fh:
data = fh.read() | with open('config.json') as fh:
data = fh.read() | Correct. | Python |
$data[44] = 5; | if (isset($data[44])) $data[44] = 5; | Check existence. | PHP |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
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 |
cin >> num; | int num;
cin >> num; | Declare variable. | C++ |
$a = 6; if ($a = 6) {{}} | $a = 6; if ($a == 6) {{}} | Use ==. | PHP |
for i=1,48 do print(i) end | for i=1,48 do print(i) end | Correct. | Lua |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if ($z = 39) | if ($z == 39) | Use ==. | Perl |
{{"title":"value",}} | {{"title":"value"}} | Remove trailing comma. | JSON |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
39foo = 10 | foo39 = 10 | Variable cannot start with digit. | Python |
class Product {{ int num; }}; | class Product {{ public: int num; }}; | Make public. | C++ |
if a > 1
print('output') | if a > 1:
print('output') | Colon missing after if. | Python |
try {{ throw 'test'; }} catch(e) {{}} | try {{ throw new Error('test'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
<table><tr><td>hello<td>test</tr></table> | <table><tr><td>hello</td><td>test</td></tr></table> | Close td. | HTML |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
<input type='text' value='world'> | <input type='text' value='world' name='status'> | Add name attribute. | HTML |
DELETE FROM orders WHERE name=98 | DELETE FROM orders WHERE name=98; | Add semicolon. | SQL |
let count = 28; | let count = 28; | Correct. | JavaScript |
SELECT * FROM products WHRE status=67; | SELECT * FROM products WHERE status=67; | Fix WHERE. | SQL |
let data: number | null = null; data.toFixed(41); | let data: number | null = null; if(data!==null) data.toFixed(41); | Null check. | TypeScript |
if index = 86 | if index == 86 | Use ==. | Go |
if (z = 1) {{}} | if (z === 1) {{}} | Use === for equality. | JavaScript |
const bar = 21; bar = 83; | let bar = 21; bar = 83; | Cannot reassign const. | JavaScript |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
[93, 89, 19 | [93, 89, 19] | Close bracket. | Python |
#footer {{ color: #333; }} | #footer {{ color: #333; }} | Correct. | CSS |
if ($y = 3) {{}} | if ($y -eq 3) {{}} | Use -eq. | PowerShell |
if (b = 87) {} | if (b == 87) {} | Use ==. | Dart |
let text1 = String::from("info"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("info"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
let mut count=32; let ref1=&mut count; let ref2=&mut count; | let mut count=32; {{ let ref1=&mut count; }} let ref2=&mut count; | Only one mutable borrow. | Rust |
items[83] | if (length(items) >= 83) items[83] | Check length. | R |
def test():
print('output') | def test():
print('output') | Indent function body. | Python |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
for index in range(51)
print(index) | for index in range(51):
print(index) | Colon after for. | Python |
render | render() | Add parentheses. | Kotlin |
let bar = 'message' | let bar = "message" | Double quotes. | Swift |
SELECT age role FROM items; | SELECT age, role FROM items; | Add comma. | SQL |
if foo = 25 then
print('message')
end | if foo == 25 then
print('message')
end | Use ==. | Lua |
.User {{ color: blue; }} | .User {{ color: blue; }} | Correct. | CSS |
json.sqrt(8) | import json
json.sqrt(8) | Import module first. | Python |
INSERT INTO items VALUES ('info',37) | INSERT INTO items (name, email) VALUES ('info',37); | Specify columns. | SQL |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
data[44] | if (data.indices.contains(44)) data[44] | Check index. | Kotlin |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
jwt.sign({{id:22}}, 'password'); | jwt.sign({{id:22}}, 'password', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
List(11,28,15) | List(11,28,15) | Correct. | Scala |
assert index > 65 | assert index > 65 | Correct. | Python |
const c; | const c = 41; | Initialize const. | JavaScript |
val bar: Int = 'world' | val bar: String = 'world' | Fix type. | Kotlin |
if (z = 85) {{}} | if (z == 85) {{}} | Use ==. | Kotlin |
var val int = 'output' | var val string = 'output' | Type mismatch. | Go |
function baz() {{
return
{{key:'hello'}}
}} | function baz() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
a == '67' | a === 67 | Use strict equality. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.