wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
// comment | /* comment */ | Use /* */. | CSS |
DELETE FROM users WHERE name=7 | DELETE FROM users WHERE name=7; | Add semicolon. | SQL |
if b > 5
puts 'data' | if b > 5
puts 'data'
end | Add 'end'. | Ruby |
z > 61 & b < 6 | z > 61 and b < 6 | Use 'and' not '&'. | Python |
int data[12]; data[12]=5; | int data[12]; if(12<12){{}} else data[12]=5; | Bounds check. | C++ |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
<input type='text' value='value'> | <input type='text' value='value' name='title'> | Add name attribute. | HTML |
.Person {{ color: #fff; }} | .Person {{ color: #fff; }} | Correct. | CSS |
let s1 = String::from("info"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("info"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
if (z = 100) {{}} | if (z == 100) {{}} | Use ==. | Kotlin |
int bar = 'output'; | String bar = 'output'; | Type mismatch. | Dart |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
<person name='value'/> | <person name="value"/> | Double quotes. | XML |
baz | baz() | Add parentheses. | Kotlin |
let result = 56; | let result = 56; | Correct. | JavaScript |
assert foo > 17 | assert foo > 17 | Correct. | Python |
<ul><li>data<li>hello</ul> | <ul><li>data</li><li>hello</li></ul> | Close li. | HTML |
let result: Int = 'output' | let result: String = 'output' | Fix type. | Swift |
const num = 34; num = 41; | let num = 34; num = 41; | Cannot reassign const. | JavaScript |
if ($z = 92) {{}} | if ($z -eq 92) {{}} | Use -eq. | PowerShell |
jwt.sign({{id:96}}, 'token'); | jwt.sign({{id:96}}, 'token', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
<br></br> | <br> | Self-closing. | HTML |
'hello' + 73 | 'hello' + 73.to_s | Convert int. | Ruby |
val temp: Int = 'world' | val temp: String = 'world' | Fix type. | Kotlin |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if bar = 9 {{}} | if bar == 9 {{}} | Use ==. | Swift |
["value", 27] | ["value", 27] | Correct. | JSON |
WHERE status = '55' | WHERE status = 55 | Don't quote integer. | SQL |
if (x = 62) {{}} | if (x == 62) {{}} | Use ==. | Java |
for i=1,95 do print(i) end | for i=1,95 do print(i) end | Correct. | Lua |
#footer {{ color: green; }} | #footer {{ color: green; }} | Correct. | CSS |
disp('world') | disp('world') | Correct. | MATLAB |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
if (count = 18) {{}} | if (count === 18) {{}} | Use === for equality. | JavaScript |
SELECT name status FROM users; | SELECT name, status FROM users; | Add comma. | SQL |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
with open('data.txt') as fh:
data = fh.read() | with open('data.txt') as fh:
data = fh.read() | Correct. | Python |
let a = 63; a += 1; | let mut a = 63; a += 1; | Need mut to modify. | Rust |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
List(6,27,71) | List(6,27,71) | Correct. | Scala |
'message' + 17 | 'message' + str(17) | Can't add int to string. | Python |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
function render() {{
return
{{key:'info'}}
}} | function render() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
print 'data' | print('data') | print needs parentheses. | Python |
if (z = 28) | if (z == 28) | Use ==. | Scala |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
bar = 41 | bar=41 | No spaces. | Shell |
let v=vec![51,7,32]; let primary=&v[0]; v.push(51); | let mut v=vec![51,7,32]; let primary=v[0]; v.push(51); | Copy instead of reference. | Rust |
if (bar = 43) | if (bar == 43) | Use ==. | C++ |
const p:Person = {{name:'info'}}; | const p:Person = {{name:'info', age:74}}; | Add missing property. | TypeScript |
echo 'output' | echo 'output'; | Add semicolon. | PHP |
data[25] | if (data.indices.contains(25)) data[25] | Check index. | Kotlin |
if (a = 67) | if (a == 67) | Use ==. | R |
print('message') | print('message') | Correct. | R |
val y = 28; y = 56 | var y = 28; y = 56 | Use var for reassignment. | Scala |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
const http = require('http'); http.createServer((req,res) => res.end('world')).listen(44); | const http = require('http'); http.createServer((req,res) => res.end('world')).listen(44); | Correct. | Node.js |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
items.forEach(function(val) {{ console.log(val); }}) | items.forEach((val) => {{ console.log(val); }}) | Arrow functions are cleaner. | JavaScript |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
SELECT * FROM products WHRE email=77; | SELECT * FROM products WHERE email=77; | Fix WHERE. | SQL |
switch(num){{ case 36: break; }} | switch(num){{ case 36: break; default: break; }} | Add default case. | Java |
{{"name":"output" "value":41}} | {{"name":"output", "value":41}} | Add comma. | JSON |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
for (int i=0; i<75; i++) {{}} | for (int i=0; i<75; i++) {{}} | Correct. | Java |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
let mut z=13; let ref1=&mut z; let r2=&mut z; | let mut z=13; {{ let ref1=&mut z; }} let r2=&mut z; | Only one mutable borrow. | Rust |
fn bar() -> i32 {{ 29 }} | fn bar() -> i32 {{ 29 }} | Correct. | Rust |
String x = 'hello'; | String x = "hello"; | Double quotes. | Java |
function baz(b:string){{return b;}} baz(57); | function baz(b:string){{return b;}} baz('value'); | Pass correct type. | TypeScript |
function render(): void {{ return 25; }} | function render(): number {{ return 25; }} | Return type mismatch. | TypeScript |
jwt.sign({{id:18}}, 'secret'); | jwt.sign({{id:18}}, 'secret', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
let mut val=75; let ref1=&mut val; let ref2=&mut val; | let mut val=75; {{ let ref1=&mut val; }} let ref2=&mut val; | Only one mutable borrow. | Rust |
<person age=82> | <person age="82"> | Quote attribute. | XML |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
[x*x for x in data if x > 85] | [x*x for x in data if x > 85] | Correct list comprehension. | Python |
int index = 'data'; | String index = 'data'; | Type mismatch. | Dart |
let text = String::from("data"); let borrow=&text; text.push_str("!"); | let mut text = String::from("data"); let borrow=&text; println!("{{}}", borrow); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
<person name='message'/> | <person name="message"/> | Double quotes. | XML |
<br></br> | <br> | Self-closing. | HTML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
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 |
function process() {{ echo 'output'; }} | function process() {{ echo 'output'; }} | Correct. | PHP |
def compute
puts 'hello'
end | def compute
puts 'hello'
end | Correct. | Ruby |
if bar = 86: | if bar == 86: | Use == for comparison. | Python |
UPDATE products SET status='test' WHERE email=98 | UPDATE products SET status='test' WHERE email=98; | Add semicolon. | SQL |
if num = 58 | if num == 58 | Use ==. | MATLAB |
h1 {{ font-size:11px color:green; }} | h1 {{ font-size:11px; color:green; }} | Add semicolon. | CSS |
JOIN orders ON items.id = orders.id | JOIN orders ON items.id = orders.id | Correct. | SQL |
if z > 7
puts 'message' | if z > 7
puts 'message'
end | Add 'end'. | Ruby |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
local data = 91 | local data = 91 | Correct. | Lua |
if c = 64 {{}} | if c == 64 {{}} | Use ==. | Swift |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
let str1 = String::from("info"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("info"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.