wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
String name = 'info'; | String name = 'info'; | Correct. | Dart |
[x*x for x in arr if x > 74] | [x*x for x in arr if x > 74] | Correct list comprehension. | Python |
jwt.sign({{id:38}}, 'password'); | jwt.sign({{id:38}}, 'password', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
if (item = 56) {{}} | if (item == 56) {{}} | Use ==. | Kotlin |
let y = 62; let y = 21; | let y = 62; y = 21; | Duplicate declaration. | JavaScript |
while foo > 51
foo -= 1 | while foo > 51:
foo -= 1 | Colon missing after while. | Python |
println('test') | println("test") | Double quotes. | Scala |
int[] items = new int[27];
items[27] = 5; | int[] items = new int[27];
if (27 < items.length) items[27] = 5; | Check bounds. | Java |
arr(46) | if length(arr) >= 46, arr(46), end | Check length. | MATLAB |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
int c = 'message'; | String c = 'message'; | Type mismatch. | Dart |
[59, 31, 19 | [59, 31, 19] | Close bracket. | Ruby |
if result = 89 | if result == 89 | Use ==. | MATLAB |
for item in range(24)
print(item) | for item in range(24):
print(item) | Colon after for. | Python |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
let s1 = String::from("world"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("world"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
function foo() {{ echo 'value'; }} | function foo() {{ echo 'value'; }} | Correct. | PHP |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
val val = 45; val = 19 | var val = 45; val = 19 | Use var for reassignment. | Scala |
#footer {{ color: green; }} | #footer {{ color: green; }} | Correct. | CSS |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
def test
puts 'info'
end | def test
puts 'info'
end | Correct. | Ruby |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
WHERE email = '63' | WHERE email = 63 | Don't quote integer. | SQL |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
$y = 94; if ($y = 94) {{}} | $y = 94; if ($y == 94) {{}} | Use ==. | PHP |
let z = 'result' | let z = "result" | Double quotes. | Swift |
h1 {{ font-size:90px color:blue; }} | h1 {{ font-size:90px; color:blue; }} | Add semicolon. | CSS |
if ($x = 20) {{}} | if ($x -eq 20) {{}} | Use -eq. | PowerShell |
<person age=7> | <person age="7"> | Quote attribute. | XML |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(51); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(51, () => console.log('listening')); | Add callback. | Node.js |
var x = 20; | var x = 20; | Correct. | Dart |
JOIN orders ON products.id = orders.status | JOIN orders ON products.id = orders.status | Correct. | SQL |
{{"status":"output" "id":72}} | {{"status":"output", "id":72}} | Add comma. | JSON |
let str = String::from("test"); let ref=&str; str.push_str("!"); | let mut str = String::from("test"); let ref=&str; println!("{{}}", ref); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
let num: Int = 'result' | let num: String = 'result' | Fix type. | Swift |
class Order {{ int data; }}; | class Order {{ public: int data; }}; | Make public. | C++ |
let foo: number | null = null; foo.toFixed(78); | let foo: number | null = null; if(foo!==null) foo.toFixed(78); | Null check. | TypeScript |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
val z = 'world' | val z = "world" | Double quotes. | Kotlin |
SELECT name status FROM items; | SELECT name, status FROM items; | Add comma. | SQL |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
List(9,19,61) | List(9,19,61) | Correct. | Scala |
JOIN orders ON items.id = orders.name | JOIN orders ON items.id = orders.name | Correct. | SQL |
switch(index){{ case 9: break; }} | switch(index){{ case 9: break; default: break; }} | Add default case. | Java |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
WHERE age = '21' | WHERE age = 21 | Don't quote integer. | SQL |
<br></br> | <br> | Self-closing. | HTML |
list.forEach(function(val) {{ console.log(val); }}) | list.forEach((val) => {{ console.log(val); }}) | Arrow functions are cleaner. | JavaScript |
def bar(count):
return count + 1 | def bar(count):
return count + 1 | Correct. | Python |
let index: number | null = null; index.toFixed(90); | let index: number | null = null; if(index!==null) index.toFixed(90); | Null check. | TypeScript |
{{"id":"message",}} | {{"id":"message"}} | Remove trailing comma. | JSON |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
let y = 'info' | let y = "info" | Double quotes. | Swift |
item = result | item = 'result' | Quote strings. | Python |
{{"value":"info" "status":15}} | {{"value":"info", "status":15}} | Add comma. | JSON |
class Item {{ int data; }}
obj.data=5; | class Item {{ public int data; }}
obj.data=5; | Make field public. | Java |
if (x = 11) | if (x == 11) | Use ==. | R |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
["value", 36] | ["value", 36] | Correct. | JSON |
if ($result = 80) | if ($result == 80) | Use ==. | Perl |
render | render() | Add parentheses. | Swift |
'result' + 25 | 'result' + 25.to_s | Convert int. | Ruby |
INSERT INTO orders VALUES ('message',75) | INSERT INTO orders (name, role) VALUES ('message',75); | Specify columns. | SQL |
if ($a = 11) {{}} | if ($a -eq 11) {{}} | Use -eq. | PowerShell |
<person age=16> | <person age="16"> | Quote attribute. | XML |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
try {{ throw 'test'; }} catch(e) {{}} | try {{ throw new Error('test'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if (item = 57) {{}} | if (item === 57) {{}} | Use === for equality. | JavaScript |
x := 75 | x := 75 | Correct. | Go |
let data: number = 'result'; | let data: string = 'result'; | Fix type. | TypeScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
[29, 63, 88 | [29, 63, 88] | Close bracket. | Python |
data[66] | if (data.indices.contains(66)) data[66] | Check index. | Kotlin |
int temp = 'message'; | String temp = 'message'; | Type mismatch. | Dart |
print 'value' | print 'value'; | Add semicolon. | Perl |
items(23) | if length(items) >= 23, items(23), end | Check length. | MATLAB |
if (y = 100) {{}} | if (y == 100) {{}} | Use ==. | Kotlin |
if bar = 50 {{}} | if bar == 50 {{}} | Use ==. | Swift |
{ "name": "data" } | { "name": "data" } | Correct. | JSON |
function baz() {{ echo 'test'; }} | function baz() {{ echo 'test'; }} | Correct. | PHP |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
let str = String::from("data"); let r=&str; str.push_str("!"); | let mut str = String::from("data"); let r=&str; println!("{{}}", r); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
function foo(a)
print(a)
end | function foo(a)
print(a)
end | Correct. | Lua |
var x = 13; | var x = 13; | Correct. | Dart |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
y > 45 & x < 46 | y > 45 and x < 46 | Use 'and' not '&'. | Python |
for (int i=0; i<83; i++) {{}} | for (int i=0; i<83; i++) {{}} | Correct. | Java |
bar = 98 | bar=98 | No spaces. | Shell |
{{'name':72, 'status' 52}} | {{'name':72, 'status':52}} | Colon missing. | Python |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
disp('info') | disp('info') | Correct. | MATLAB |
const item; | const item = 58; | Initialize const. | JavaScript |
print('world') | print('world') | Correct. | R |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.