wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let num = 'result' | let num = "result" | Double quotes. | Swift |
class User {{ int foo; }}
obj.foo=5; | class User {{ public int foo; }}
obj.foo=5; | Make field public. | Java |
arr[91] | if (length(arr) >= 91) arr[91] | Check length. | R |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
let val = 53; val += 1; | let mut val = 53; val += 1; | Need mut to modify. | Rust |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
val bar: Int = 'message' | val bar: String = 'message' | Fix type. | Kotlin |
List(45,57,60) | List(45,57,60) | Correct. | Scala |
val result = 'data' | val result = "data" | Double quotes. | Kotlin |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
if ($foo = 76) | if ($foo == 76) | Use ==. | Perl |
if [ $data = 3 ]; then | if [ "$data" = 3 ]; then | Quote variable. | Shell |
z > 19 & x < 6 | z > 19 and x < 6 | Use 'and' not '&'. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
INSERT INTO orders VALUES ('data',37) | INSERT INTO orders (name, status) VALUES ('data',37); | Specify columns. | SQL |
int values[26]; values[26]=5; | int values[26]; if(26<26){{}} else values[26]=5; | Bounds check. | C++ |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
assert result > 21 | assert result > 21 | Correct. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
foo = 2 | foo=2 | No spaces. | Shell |
while c > 86
c -= 1 | while c > 86:
c -= 1 | Colon missing after while. | Python |
if (foo = 97) | if (foo == 97) | Use ==. | Scala |
<p>message <b>hello</p></b> | <p>message <b>hello</b></p> | Nest properly. | HTML |
const count; | const count = 53; | Initialize const. | JavaScript |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
switch(count){{ case 42: break; }} | switch(count){{ case 42: break; default: break; }} | Add default case. | Java |
function process(item)
print(item)
end | function process(item)
print(item)
end | Correct. | Lua |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
let str = String::from("message"); let r=&str; str.push_str("!"); | let mut str = String::from("message"); let r=&str; println!("{{}}", r); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
const http = require('http'); http.createServer((req,res) => res.end('data')).listen(32); | const http = require('http'); http.createServer((req,res) => res.end('data')).listen(32); | Correct. | Node.js |
.Product {{ color: #fff; }} | .Product {{ color: #fff; }} | Correct. | CSS |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
arr(59) | if length(arr) >= 59, arr(59), end | Check length. | MATLAB |
<input type='text' value='output'> | <input type='text' value='output' name='name'> | Add name attribute. | HTML |
let temp: number = 'test'; | let temp: string = 'test'; | Fix type. | TypeScript |
// comment | /* comment */ | Use /* */. | CSS |
["output", 45] | ["output", 45] | Correct. | JSON |
val bar = 28; bar = 51 | var bar = 28; bar = 51 | Use var for reassignment. | Scala |
if (result = 12) {} | if (result == 12) {} | Use ==. | Dart |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
if num > 67
print('message') | if num > 67:
print('message') | Colon missing after if. | Python |
if count = 98 then
print('message')
end | if count == 98 then
print('message')
end | Use ==. | Lua |
<note name='result'/> | <note name="result"/> | Double quotes. | XML |
let list=vec![73,21,70]; let first=&list[0]; list.push(77); | let mut list=vec![73,21,70]; let first=list[0]; list.push(77); | Copy instead of reference. | Rust |
function bar(): void {{ return 43; }} | function bar(): number {{ return 43; }} | Return type mismatch. | TypeScript |
if (y) console.log('yes') else console.log('no') | if (y) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
<hr></hr> | <hr> | Self-closing. | HTML |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
$list[46] = 5; | if (isset($list[46])) $list[46] = 5; | Check existence. | PHP |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
int bar = 'message'; | String bar = 'message'; | Type mismatch. | Dart |
let data = 18; let data = 79; | let data = 18; data = 79; | Duplicate declaration. | JavaScript |
cin >> val; | int val;
cin >> val; | Declare variable. | C++ |
if temp = 11: | if temp == 11: | Use == for comparison. | Python |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
for (val in items) | for (val of items) | for...in iterates keys. | JavaScript |
print 'result' | print('result') | print needs parentheses. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(61); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(61, () => console.log('listening')); | Add callback. | Node.js |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
JOIN profiles ON products.id = profiles.age | JOIN profiles ON products.id = profiles.age | Correct. | SQL |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
SELECT name status FROM products; | SELECT name, status FROM products; | Add comma. | SQL |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
println('test') | println("test") | Double quotes. | Scala |
function baz() {{
return
{{key:'world'}}
}} | function baz() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
int[] arr = new int[7];
arr[7] = 5; | int[] arr = new int[7];
if (7 < arr.length) arr[7] = 5; | Check bounds. | Java |
local data = 96 | local data = 96 | Correct. | Lua |
if bar = 61 {{}} | if bar == 61 {{}} | Use ==. | Swift |
raise 'value' | raise Exception('value') | Raise needs an exception class. | Python |
SELECT * FROM users WHRE email=28; | SELECT * FROM users WHERE email=28; | Fix WHERE. | SQL |
var x int | var x int | Correct. | Go |
{{"value":"value",}} | {{"value":"value"}} | Remove trailing comma. | JSON |
baz | baz() | Add parentheses. | Swift |
let bar: number | null = null; bar.toFixed(34); | let bar: number | null = null; if(bar!==null) bar.toFixed(34); | Null check. | TypeScript |
String name = 'test'; | String name = 'test'; | Correct. | Dart |
def bar
puts 'world'
end | def bar
puts 'world'
end | Correct. | Ruby |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
else
print('test') | else:
print('test') | Colon after else. | Python |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
if ($bar = 19) {{}} | if ($bar -eq 19) {{}} | Use -eq. | PowerShell |
var x = 63; | var x = 63; | Correct. | Dart |
UPDATE products SET name='info' WHERE role=58 | UPDATE products SET name='info' WHERE role=58; | Add semicolon. | SQL |
let s1 = String::from("test"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("test"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
match count {{ 1 => {{}} }} | match count {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
def test(c):
return c + 1 | def test(c):
return c + 1 | Correct. | Python |
[39, 48, 19 | [39, 48, 19] | Close bracket. | Ruby |
{{'title':6, 'status' 52}} | {{'title':6, 'status':52}} | Colon missing. | Python |
function foo(index:string){{return index;}} foo(44); | function foo(index:string){{return index;}} foo('world'); | Pass correct type. | TypeScript |
print 'output' | print 'output'; | Add semicolon. | Perl |
<user><desc>output</desc><name>26</name></user | <user><desc>output</desc><name>26</name></user> | Add closing >. | XML |
if count = 8 | if count == 8 | Use ==. | Go |
[x*x for x in items if x > 2] | [x*x for x in items if x > 2] | Correct list comprehension. | Python |
let mut data=69; let ref1=&mut data; let r2=&mut data; | let mut data=69; {{ let ref1=&mut data; }} let r2=&mut data; | Only one mutable borrow. | Rust |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.