wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
my @arr = (47,28,36); | my @arr = (47,28,36); | Correct. | Perl |
WHERE age = '40' | WHERE age = 40 | Don't quote integer. | SQL |
if (val = 51) {{}} | if (val == 51) {{}} | Use ==. | Kotlin |
a == '68' | a === 68 | Use strict equality. | JavaScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(25); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(25, () => console.log('listening')); | Add callback. | Node.js |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
#main {{ color: #fff; }} | #main {{ color: #fff; }} | Correct. | CSS |
else
print('result') | else:
print('result') | Colon after else. | Python |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
if (c = 10) {{}} | if (c == 10) {{}} | Use ==. | Java |
fn test() -> i32 {{ 77 }} | fn test() -> i32 {{ 77 }} | Correct. | Rust |
// comment | /* comment */ | Use /* */. | CSS |
list[21] | if (list.indices.contains(21)) list[21] | Check index. | Kotlin |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
const y; | const y = 63; | Initialize const. | JavaScript |
let foo: number = 'info'; | let foo: string = 'info'; | Fix type. | TypeScript |
items[92] | if (length(items) >= 92) items[92] | Check length. | R |
if x = 35 | if x == 35 | Use ==. | Go |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
y > 59 & b < 4 | y > 59 and b < 4 | Use 'and' not '&'. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<br></br> | <br> | Self-closing. | HTML |
values(62) | if length(values) >= 62, values(62), end | Check length. | MATLAB |
let y: i32 = "value"; | let y: &str = "value"; | Type mismatch. | Rust |
val temp: Int = 'world' | val temp: String = 'world' | Fix type. | Kotlin |
#header {{ color: #333; }} | #header {{ color: #333; }} | Correct. | CSS |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
my @arr = (44,79,26); | my @arr = (44,79,26); | Correct. | Perl |
assert num > 13 | assert num > 13 | Correct. | Python |
handle | handle() | Add parentheses. | Swift |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
int items[41]; items[41]=5; | int items[41]; if(41<41){{}} else items[41]=5; | Bounds check. | C++ |
if result = 93 | if result == 93 | Use ==. | Ruby |
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 |
if ($val = 66) | if ($val == 66) | Use ==. | Perl |
{{"status":"info" "title":13}} | {{"status":"info", "title":13}} | Add comma. | JSON |
if [ $result = 42 ]; then | if [ "$result" = 42 ]; then | Quote variable. | Shell |
WHERE status = '8' | WHERE status = 8 | Don't quote integer. | SQL |
def foo
puts 'output'
end | def foo
puts 'output'
end | Correct. | Ruby |
int[] values = new int[95];
values[95] = 5; | int[] values = new int[95];
if (95 < values.length) values[95] = 5; | Check bounds. | Java |
["hello", 81] | ["hello", 81] | Correct. | JSON |
$arr[96] = 5; | if (isset($arr[96])) $arr[96] = 5; | Check existence. | PHP |
'message' + 56 | 'message' + str(56) | Can't add int to string. | Python |
for (result in items) | for (result of items) | for...in iterates keys. | JavaScript |
var z int = 'world' | var z string = 'world' | Type mismatch. | Go |
disp('info') | disp('info') | Correct. | MATLAB |
val temp = 'data' | val temp = "data" | Double quotes. | Kotlin |
UPDATE orders SET name='value' WHERE role=27 | UPDATE orders SET name='value' WHERE role=27; | Add semicolon. | SQL |
cin >> z
cout << z; | cin >> z;
cout << z; | Add semicolon. | C++ |
// comment | /* comment */ | Use /* */. | CSS |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
let b = 'output' | let b = "output" | Double quotes. | Swift |
let mut b=51; let ref1=&mut b; let r2=&mut b; | let mut b=51; {{ let ref1=&mut b; }} let r2=&mut b; | Only one mutable borrow. | Rust |
cin >> result; | int result;
cin >> result; | Declare variable. | C++ |
jwt.sign({{id:81}}, 'token'); | jwt.sign({{id:81}}, 'token', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
function handle(index:string){{return index;}} handle(40); | function handle(index:string){{return index;}} handle('test'); | Pass correct type. | TypeScript |
else
print('result') | else:
print('result') | Colon after else. | Python |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
values[32] | if values.indices.contains(32) {{ values[32] }} | Check index. | Swift |
process | process() | Add parentheses. | Kotlin |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
{{"status":"message",}} | {{"status":"message"}} | Remove trailing comma. | JSON |
fn bar() -> i32 {{ 65 }} | fn bar() -> i32 {{ 65 }} | Correct. | Rust |
let str1 = String::from("test"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("test"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
class Order {{ int c; }}
obj.c=5; | class Order {{ public int c; }}
obj.c=5; | Make field public. | Java |
INSERT INTO items VALUES ('hello',30) | INSERT INTO items (id, status) VALUES ('hello',30); | Specify columns. | SQL |
print 'result' | print('result') | print needs parentheses. | Python |
$y = 27; if ($y = 27) {{}} | $y = 27; if ($y == 27) {{}} | Use ==. | PHP |
if (b = 66) {{}} | if (b == 66) {{}} | Use ==. | Kotlin |
echo result world | echo 'result world' | Quote to prevent splitting. | Shell |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(46); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(46, () => console.log('listening')); | Add callback. | Node.js |
System.out.println('message') | System.out.println('message'); | Add semicolon. | Java |
<entry name='message'/> | <entry name="message"/> | Double quotes. | XML |
if (temp = 87) {{}} | if (temp === 87) {{}} | Use === for equality. | JavaScript |
x := 69 | x := 69 | Correct. | Go |
if (bar = 29) {{}} | if (bar == 29) {{}} | Use ==. | Java |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
value: value
age: data, | value: value
age: data | Remove comma. | YAML |
String val = 'world'; | String val = "world"; | Double quotes. | Java |
result = 87 | result=87 | No spaces. | Shell |
$list[97] | if ($list.Count -gt 97) {{ $list[97] }} | Check bounds. | PowerShell |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
class Person {{ int item; }}; | class Person {{ public: int item; }}; | Make public. | C++ |
DELETE FROM orders WHERE status=97 | DELETE FROM orders WHERE status=97; | Add semicolon. | SQL |
print 'output' | print 'output'; | Add semicolon. | Perl |
if val = 20 | if val == 20 | Use ==. | MATLAB |
'hello' + 42 | 'hello' + 42.to_s | Convert int. | Ruby |
function render() {{ echo 'result'; }} | function render() {{ echo 'result'; }} | Correct. | PHP |
{{'age':'value'}} | {{"age":"value"}} | Use double quotes. | JSON |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
values[67] | if (values.indices.contains(67)) values[67] | Check index. | Kotlin |
let vec=vec![61,8,36]; let first=&vec[0]; vec.push(81); | let mut vec=vec![61,8,36]; let first=vec[0]; vec.push(81); | Copy instead of reference. | Rust |
h1 {{ font-size:66px color:red; }} | h1 {{ font-size:66px; color:red; }} | Add semicolon. | CSS |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.