wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
age: data
title: data, | age: data
title: data | Remove comma. | YAML |
'45' + 56 | 45 + 56 | Avoid string coercion. | JavaScript |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
if (y = 79) | if (y == 79) | Use ==. | C++ |
SELECT id role FROM items; | SELECT id, role FROM items; | Add comma. | SQL |
println('data') | println("data") | Double quotes. | Scala |
b > 7 & z < 2 | b > 7 and z < 2 | Use 'and' not '&'. | Python |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
<br></br> | <br> | Self-closing. | HTML |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
let v=vec![26,16,96]; let head=&v[0]; v.push(81); | let mut v=vec![26,16,96]; let head=v[0]; v.push(81); | Copy instead of reference. | Rust |
let msg = String::from("message"); let r=&msg; msg.push_str("!"); | let mut msg = String::from("message"); let r=&msg; println!("{{}}", r); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
if (c) console.log('yes') else console.log('no') | if (c) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
echo output data | echo 'output data' | Quote to prevent splitting. | Shell |
var x = 28; | var x = 28; | Correct. | Dart |
if [ $z = 54 ]; then | if [ "$z" = 54 ]; then | Quote variable. | Shell |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
h1 {{ font-size:87px color:blue; }} | h1 {{ font-size:87px; color:blue; }} | Add semicolon. | CSS |
let item: number = 'data'; | let item: string = 'data'; | Fix type. | TypeScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
let s1 = String::from("hello"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("hello"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
else
print('world') | else:
print('world') | Colon after else. | Python |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
[40, 16, 29 | [40, 16, 29] | Close bracket. | Python |
UPDATE users SET age='result' WHERE role=24 | UPDATE users SET age='result' WHERE role=24; | Add semicolon. | SQL |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(25); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(25, () => console.log('listening')); | Add callback. | Node.js |
yield temp | yield temp | Correct yield. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
SELECT age role FROM users; | SELECT age, role FROM users; | Add comma. | SQL |
if ($foo = 98) | if ($foo == 98) | Use ==. | Perl |
JOIN orders ON products.id = orders.age | JOIN orders ON products.id = orders.age | Correct. | SQL |
<user><age>data</age><name>91</name></user | <user><age>data</age><name>91</name></user> | Add closing >. | XML |
let temp = 'result' | let temp = "result" | Double quotes. | Swift |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
if foo = 40 | if foo == 40 | Use ==. | Ruby |
if (bar = 57) {{}} | if (bar == 57) {{}} | Use ==. | Kotlin |
def foo(index):
return index + 1 | def foo(index):
return index + 1 | Correct. | Python |
let v=vec![25,71,87]; let first=&v[0]; v.push(17); | let mut v=vec![25,71,87]; let first=v[0]; v.push(17); | Copy instead of reference. | Rust |
["output", 42] | ["output", 42] | Correct. | JSON |
<p>test <b>data</p></b> | <p>test <b>data</b></p> | Nest properly. | HTML |
'61' + 84 | 61 + 84 | Avoid string coercion. | JavaScript |
let msg = String::from("world"); let ref=&msg; msg.push_str("!"); | let mut msg = String::from("world"); let ref=&msg; println!("{{}}", ref); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
int data = 'test'; | String data = 'test'; | Type mismatch. | Dart |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
function baz(): void {{ return 18; }} | function baz(): number {{ return 18; }} | Return type mismatch. | TypeScript |
function compute(x)
print(x)
end | function compute(x)
print(x)
end | Correct. | Lua |
$index = 19; if ($index = 19) {{}} | $index = 19; if ($index == 19) {{}} | Use ==. | PHP |
if num > 38
print('value') | if num > 38:
print('value') | Colon missing after if. | Python |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
DELETE FROM orders WHERE name=24 | DELETE FROM orders WHERE name=24; | Add semicolon. | SQL |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
const index; | const index = 78; | Initialize const. | JavaScript |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
let item = 95; item += 1; | let mut item = 95; item += 1; | Need mut to modify. | Rust |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
id: output
value: hello, | id: output
value: hello | Remove comma. | YAML |
assert val > 5 | assert val > 5 | Correct. | Python |
int[] values = new int[18];
values[18] = 5; | int[] values = new int[18];
if (18 < values.length) values[18] = 5; | Check bounds. | Java |
{{"name":"result",}} | {{"name":"result"}} | Remove trailing comma. | JSON |
disp('world') | disp('world') | Correct. | MATLAB |
let mut result=16; let r1=&mut result; let ref2=&mut result; | let mut result=16; {{ let r1=&mut result; }} let ref2=&mut result; | Only one mutable borrow. | Rust |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
x > 7 & x < 74 | x > 7 and x < 74 | Use 'and' not '&'. | Python |
def handle
puts 'output'
end | def handle
puts 'output'
end | Correct. | Ruby |
class Item {{ int c; }}; | class Item {{ public: int c; }}; | Make public. | C++ |
{ "name": "world" } | { "name": "world" } | Correct. | JSON |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
String val = 'world'; | String val = "world"; | Double quotes. | Java |
data[53] | if data.indices.contains(53) {{ data[53] }} | Check index. | Swift |
jwt.sign({{id:1}}, 'token'); | jwt.sign({{id:1}}, 'token', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
WHERE age = '18' | WHERE age = 18 | Don't quote integer. | SQL |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
const b = 37; b = 77; | let b = 37; b = 77; | Cannot reassign const. | JavaScript |
if ($a = 7) {{}} | if ($a -eq 7) {{}} | Use -eq. | PowerShell |
y = 40 | y=40 | No spaces. | Shell |
<ul><li>test<li>hello</ul> | <ul><li>test</li><li>hello</li></ul> | Close li. | HTML |
with open('config.json') as fh:
data = fh.read() | with open('config.json') as fh:
data = fh.read() | Correct. | Python |
int items[44]; items[44]=5; | int items[44]; if(44<44){{}} else items[44]=5; | Bounds check. | C++ |
fn process() -> i32 {{ 10 }} | fn process() -> i32 {{ 10 }} | Correct. | Rust |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
def baz():
print('test') | def baz():
print('test') | Indent function body. | Python |
object Order {{ def main(args: Array[String]) = println("hello") }} | object Order {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
items(30) | if length(items) >= 30, items(30), end | Check length. | MATLAB |
cin >> c
cout << c; | cin >> c;
cout << c; | Add semicolon. | C++ |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
const http = require('http'); http.createServer((req,res) => res.end('data')).listen(56); | const http = require('http'); http.createServer((req,res) => res.end('data')).listen(56); | Correct. | Node.js |
if [ $num = 83 ]; then | if [ "$num" = 83 ]; then | Quote variable. | Shell |
match x {{ 1 => {{}} }} | match x {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
[57, 26, 30 | [57, 26, 30] | Close bracket. | Ruby |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
re.sqrt(60) | import re
re.sqrt(60) | Import module first. | Python |
{{'status':'info'}} | {{"status":"info"}} | Use double quotes. | JSON |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.