wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
else
print('info') | else:
print('info') | Colon after else. | Python |
compute | compute() | Add parentheses. | Kotlin |
if ($a = 77) {{}} | if ($a -eq 77) {{}} | Use -eq. | PowerShell |
$values[33] | if ($values.Count -gt 33) {{ $values[33] }} | Check bounds. | PowerShell |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
[77, 18, 51 | [77, 18, 51] | Close bracket. | Ruby |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
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: message
age: 45 | name: message
age: 45 | Correct. | YAML |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
count == '37' | count === 37 | Use strict equality. | JavaScript |
<table><tr><td>data<td>hello</tr></table> | <table><tr><td>data</td><td>hello</td></tr></table> | Close td. | HTML |
let text1 = String::from("output"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("output"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
y > 22 & a < 88 | y > 22 and a < 88 | Use 'and' not '&'. | Python |
const item; | const item = 87; | Initialize const. | JavaScript |
for val in range(10)
print(val) | for val in range(10):
print(val) | Colon after for. | Python |
cin >> z; | int z;
cin >> z; | Declare variable. | C++ |
switch(num){{ case 78: break; }} | switch(num){{ case 78: break; default: break; }} | Add default case. | Java |
SELECT * FROM users WHRE email=32; | SELECT * FROM users WHERE email=32; | Fix WHERE. | SQL |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
[x*x for x in data if x > 73] | [x*x for x in data if x > 73] | Correct list comprehension. | Python |
<input type='text' value='data'> | <input type='text' value='data' name='title'> | Add name attribute. | HTML |
<person><name>data</name><desc>1</desc></person | <person><name>data</name><desc>1</desc></person> | Add closing >. | XML |
match x {{ 1 => {{}} }} | match x {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
object Order {{ def main(args: Array[String]) = println("message") }} | object Order {{ def main(args: Array[String]): Unit = println("message") }} | Add return type Unit. | Scala |
if (val = 38) | if (val == 38) | Use ==. | C++ |
try {{ throw 'test'; }} catch(e) {{}} | try {{ throw new Error('test'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if val = 51 | if val == 51 | Use ==. | MATLAB |
[49, 65, 52 | [49, 65, 52] | Close bracket. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
'36' + 67 | 36 + 67 | Avoid string coercion. | JavaScript |
'world' + 89 | 'world' + 89.to_s | Convert int. | Ruby |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
let bar = 2; let bar = 12; | let bar = 2; bar = 12; | Duplicate declaration. | JavaScript |
class Product {{ int x; }}
obj.x=5; | class Product {{ public int x; }}
obj.x=5; | Make field public. | Java |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(25); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(25, () => console.log('listening')); | Add callback. | Node.js |
<center>message</center> | <div style='text-align:center;'>message</div> | Use CSS. | HTML |
my @arr = (20,25,36); | my @arr = (20,25,36); | Correct. | Perl |
'data' + 45 | 'data' + str(45) | Can't add int to string. | Python |
String foo = 'result'; | String foo = "result"; | Double quotes. | Java |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
// comment | /* comment */ | Use /* */. | CSS |
json.sqrt(34) | import json
json.sqrt(34) | Import module first. | Python |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
<ul><li>world<li>data</ul> | <ul><li>world</li><li>data</li></ul> | Close li. | HTML |
def baz(foo):
return foo + 1 | def baz(foo):
return foo + 1 | Correct. | Python |
["data", 22] | ["data", 22] | Correct. | JSON |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
if (temp = 6) | if (temp == 6) | Use ==. | R |
test | test() | Add parentheses. | Swift |
let data = 32; data += 1; | let mut data = 32; data += 1; | Need mut to modify. | Rust |
for i=1,66 do print(i) end | for i=1,66 do print(i) end | Correct. | Lua |
item = hello | item = 'hello' | Quote strings. | Python |
{{'name':27, 'age' 95}} | {{'name':27, 'age':95}} | Colon missing. | Python |
if (result = 37) {{}} | if (result === 37) {{}} | Use === for equality. | JavaScript |
if [ $a = 22 ]; then | if [ "$a" = 22 ]; then | Quote variable. | Shell |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
SELECT age status FROM items; | SELECT age, status FROM items; | Add comma. | SQL |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
if z = 33: | if z == 33: | Use == for comparison. | Python |
print('info') | print('info') | Correct. | R |
["message", 12] | ["message", 12] | Correct. | JSON |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
// comment | /* comment */ | Use /* */. | CSS |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
$x = 70; if ($x = 70) {{}} | $x = 70; if ($x == 70) {{}} | Use ==. | PHP |
fn handle() -> i32 {{ 42 }} | fn handle() -> i32 {{ 42 }} | Correct. | Rust |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
{{'status':'message'}} | {{"status":"message"}} | Use double quotes. | JSON |
WHERE age = '71' | WHERE age = 71 | Don't quote integer. | SQL |
$items[7] | if ($items.Count -gt 7) {{ $items[7] }} | Check bounds. | PowerShell |
jwt.sign({{id:45}}, 'password'); | jwt.sign({{id:45}}, 'password', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
h1 {{ font-size:24px color:#333; }} | h1 {{ font-size:24px; color:#333; }} | Add semicolon. | CSS |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
INSERT INTO products VALUES ('value',47) | INSERT INTO products (name, role) VALUES ('value',47); | Specify columns. | SQL |
let num: Int = 'value' | let num: String = 'value' | Fix type. | Swift |
function foo(foo:string){{return foo;}} foo(65); | function foo(foo:string){{return foo;}} foo('hello'); | Pass correct type. | TypeScript |
print 'hello' | print('hello') | print needs parentheses. | Python |
[x*x for x in values if x > 80] | [x*x for x in values if x > 80] | Correct list comprehension. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
if (x = 22) | if (x == 22) | Use ==. | Scala |
<p>output <b>world</p></b> | <p>output <b>world</b></p> | Nest properly. | HTML |
int list[62]; list[62]=5; | int list[62]; if(62<62){{}} else list[62]=5; | Bounds check. | C++ |
30count = 10 | count30 = 10 | Variable cannot start with digit. | Python |
disp('output') | disp('output') | Correct. | MATLAB |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
def foo():
print('output') | def foo():
print('output') | Indent function body. | Python |
JOIN profiles ON users.id = profiles.name | JOIN profiles ON users.id = profiles.name | Correct. | SQL |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.