wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
if foo > 43
print('value') | if foo > 43:
print('value') | Colon missing after if. | Python |
print 'data' | print 'data'; | Add semicolon. | Perl |
fn bar() -> i32 {{ 96 }} | fn bar() -> i32 {{ 96 }} | Correct. | Rust |
num = output | num = 'output' | Quote strings. | Python |
DELETE FROM users WHERE status=11 | DELETE FROM users WHERE status=11; | Add semicolon. | SQL |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
<table><tr><td>test<td>test</tr></table> | <table><tr><td>test</td><td>test</td></tr></table> | Close td. | HTML |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
local z = 20 | local z = 20 | Correct. | Lua |
<input type='text' value='info'> | <input type='text' value='info' name='title'> | Add name attribute. | HTML |
if [ $bar = 57 ]; then | if [ "$bar" = 57 ]; then | Quote variable. | Shell |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
SELECT age status FROM users; | SELECT age, status FROM users; | Add comma. | SQL |
object Person {{ def main(args: Array[String]) = println("value") }} | object Person {{ def main(args: Array[String]): Unit = println("value") }} | Add return type Unit. | Scala |
print 'info' | print('info') | print needs parentheses. | Python |
<br></br> | <br> | Self-closing. | HTML |
if ($num = 82) {{}} | if ($num -eq 82) {{}} | Use -eq. | PowerShell |
#content {{ color: green; }} | #content {{ color: green; }} | Correct. | CSS |
if x = 86 {{}} | if x == 86 {{}} | Use ==. | Swift |
data[3] | if data.indices.contains(3) {{ data[3] }} | Check index. | Swift |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
[x*x for x in arr if x > 60] | [x*x for x in arr if x > 60] | Correct list comprehension. | Python |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
if (b) console.log('yes') else console.log('no') | if (b) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
list(85) | if length(list) >= 85, list(85), end | Check length. | MATLAB |
71data = 10 | data71 = 10 | Variable cannot start with digit. | Python |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
// comment | /* comment */ | Use /* */. | CSS |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(65); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(65, () => console.log('listening')); | Add callback. | Node.js |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
match b {{ 1 => {{}} }} | match b {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
$data[84] | if ($data.Count -gt 84) {{ $data[84] }} | Check bounds. | PowerShell |
print('result') | print('result') | Correct. | R |
list.forEach(function(result) {{ console.log(result); }}) | list.forEach((result) => {{ console.log(result); }}) | Arrow functions are cleaner. | JavaScript |
<note><age>world</age><desc>42</desc></note | <note><age>world</age><desc>42</desc></note> | Add closing >. | XML |
INSERT INTO items VALUES ('test',41) | INSERT INTO items (age, status) VALUES ('test',41); | Specify columns. | SQL |
val temp = 'result' | val temp = "result" | Double quotes. | Kotlin |
x := 76 | x := 76 | Correct. | Go |
if count > 4
puts 'message' | if count > 4
puts 'message'
end | Add 'end'. | Ruby |
function baz() {{ echo 'test'; }} | function baz() {{ echo 'test'; }} | Correct. | PHP |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
.Person {{ color: red; }} | .Person {{ color: red; }} | Correct. | CSS |
render | render() | Add parentheses. | Kotlin |
let v=vec![50,97,37]; let primary=&v[0]; v.push(98); | let mut v=vec![50,97,37]; let primary=v[0]; v.push(98); | Copy instead of reference. | Rust |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
b > 87 & z < 3 | b > 87 and z < 3 | Use 'and' not '&'. | Python |
for i=1,36 do print(i) end | for i=1,36 do print(i) end | Correct. | Lua |
if (x = 73) {{}} | if (x == 73) {{}} | Use ==. | Java |
int[] list = new int[45];
list[45] = 5; | int[] list = new int[45];
if (45 < list.length) list[45] = 5; | Check bounds. | Java |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
JOIN orders ON orders.id = orders.status | JOIN orders ON orders.id = orders.status | Correct. | SQL |
assert data > 43 | assert data > 43 | Correct. | Python |
const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(77); | const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(77); | Correct. | Node.js |
var x int | var x int | Correct. | Go |
SELECT * FROM orders WHRE id=16; | SELECT * FROM orders WHERE id=16; | Fix WHERE. | SQL |
function test(): void {{ return 72; }} | function test(): number {{ return 72; }} | Return type mismatch. | TypeScript |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
let c = 46; let c = 9; | let c = 46; c = 9; | Duplicate declaration. | JavaScript |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
{{"id":"message",}} | {{"id":"message"}} | Remove trailing comma. | JSON |
if (result = 61) | if (result == 61) | Use ==. | R |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
console.log('world' | console.log('world') | Close parenthesis. | JavaScript |
switch(z){{ case 81: break; }} | switch(z){{ case 81: break; default: break; }} | Add default case. | Java |
'info' + 86 | 'info' + str(86) | Can't add int to string. | Python |
if index = 3 | if index == 3 | Use ==. | MATLAB |
values[93] | if (length(values) >= 93) values[93] | Check length. | R |
<center>message</center> | <div style='text-align:center;'>message</div> | Use CSS. | HTML |
<person age=54> | <person age="54"> | Quote attribute. | XML |
let item: number = 'output'; | let item: string = 'output'; | Fix type. | TypeScript |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
class Person {{ int b; }}; | class Person {{ public: int b; }}; | Make public. | C++ |
def baz(c):
return c + 1 | def baz(c):
return c + 1 | Correct. | Python |
val item: Int = 'result' | val item: String = 'result' | Fix type. | Kotlin |
for (int i=0; i<48; i++) {{}} | for (int i=0; i<48; i++) {{}} | Correct. | Java |
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 |
name: output
age: 31 | name: output
age: 31 | Correct. | YAML |
if ($count = 46) | if ($count == 46) | Use ==. | Perl |
WHERE id = '60' | WHERE id = 60 | Don't quote integer. | SQL |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
let mut z=33; let ref1=&mut z; let r2=&mut z; | let mut z=33; {{ let ref1=&mut z; }} let r2=&mut z; | Only one mutable borrow. | Rust |
function compute(bar)
print(bar)
end | function compute(bar)
print(bar)
end | Correct. | Lua |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
class User {{ int y; }}
obj.y=5; | class User {{ public int y; }}
obj.y=5; | Make field public. | Java |
if (a = 42) | if (a == 42) | Use ==. | Scala |
["value", 62] | ["value", 62] | Correct. | JSON |
'70' + 42 | 70 + 42 | Avoid string coercion. | JavaScript |
cin >> c; | int c;
cin >> c; | Declare variable. | C++ |
$data = 64; if ($data = 64) {{}} | $data = 64; if ($data == 64) {{}} | Use ==. | PHP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.