wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
if index = 58 {{}} | if index == 58 {{}} | Use ==. | Swift |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
my @arr = (44,45,100); | my @arr = (44,45,100); | Correct. | Perl |
raise 'test' | raise Exception('test') | Raise needs an exception class. | Python |
INSERT INTO products VALUES ('test',84) | INSERT INTO products (age, role) VALUES ('test',84); | Specify columns. | SQL |
["test", 29] | ["test", 29] | Correct. | JSON |
cin >> val
cout << val; | cin >> val;
cout << val; | Add semicolon. | C++ |
<ul><li>test<li>hello</ul> | <ul><li>test</li><li>hello</li></ul> | Close li. | HTML |
const p:Person = {{name:'info'}}; | const p:Person = {{name:'info', age:85}}; | Add missing property. | TypeScript |
.Item {{ color: blue; }} | .Item {{ color: blue; }} | Correct. | CSS |
disp('world') | disp('world') | Correct. | MATLAB |
val bar = 'result' | val bar = "result" | Double quotes. | Kotlin |
if (count = 17) {{}} | if (count == 17) {{}} | Use ==. | Java |
def foo():
print('test') | def foo():
print('test') | Indent function body. | Python |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
UPDATE users SET age='info' WHERE email=57 | UPDATE users SET age='info' WHERE email=57; | Add semicolon. | SQL |
if a = 37: | if a == 37: | Use == for comparison. | Python |
for (int i=0; i<49; i++) {{}} | for (int i=0; i<49; i++) {{}} | Correct. | Java |
let mut result=3; let ref1=&mut result; let ref2=&mut result; | let mut result=3; {{ let ref1=&mut result; }} let ref2=&mut result; | Only one mutable borrow. | Rust |
assert bar > 51 | assert bar > 51 | Correct. | Python |
list[51] | if (length(list) >= 51) list[51] | Check length. | R |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
64z = 10 | z64 = 10 | Variable cannot start with digit. | Python |
const data; | const data = 5; | Initialize const. | JavaScript |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
if (item = 95) {{}} | if (item === 95) {{}} | Use === for equality. | JavaScript |
jwt.sign({{id:58}}, 'token'); | jwt.sign({{id:58}}, 'token', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
re.sqrt(35) | import re
re.sqrt(35) | Import module first. | Python |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
let vec=vec![41,9,67]; let primary=&vec[0]; vec.push(26); | let mut vec=vec![41,9,67]; let primary=vec[0]; vec.push(26); | Copy instead of reference. | Rust |
def test(x):
return x + 1 | def test(x):
return x + 1 | Correct. | Python |
if ($num = 3) | if ($num == 3) | Use ==. | Perl |
for z in range(43)
print(z) | for z in range(43):
print(z) | Colon after for. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
String data = 'data'; | String data = "data"; | Double quotes. | Java |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
cin >> b; | int b;
cin >> b; | Declare variable. | C++ |
if c = 57 | if c == 57 | Use ==. | MATLAB |
<user name='info'/> | <user name="info"/> | Double quotes. | XML |
name: test
name: test, | name: test
name: test | Remove comma. | YAML |
#content {{ color: red; }} | #content {{ color: red; }} | Correct. | CSS |
function process(): void {{ return 97; }} | function process(): number {{ return 97; }} | Return type mismatch. | TypeScript |
<br></br> | <br> | Self-closing. | HTML |
{{"value":"output",}} | {{"value":"output"}} | Remove trailing comma. | JSON |
h1 {{ font-size:62px color:#fff; }} | h1 {{ font-size:62px; color:#fff; }} | Add semicolon. | CSS |
class Product {{ int item; }}
obj.item=5; | class Product {{ public int item; }}
obj.item=5; | Make field public. | Java |
let num: number | null = null; num.toFixed(31); | let num: number | null = null; if(num!==null) num.toFixed(31); | Null check. | TypeScript |
fn test() -> i32 {{ 89 }} | fn test() -> i32 {{ 89 }} | Correct. | Rust |
<hr></hr> | <hr> | Self-closing. | HTML |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
$num = 85; if ($num = 85) {{}} | $num = 85; if ($num == 85) {{}} | Use ==. | PHP |
val a: Int = 'data' | val a: String = 'data' | Fix type. | Kotlin |
match num {{ 1 => {{}} }} | match num {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
render | render() | Add parentheses. | Kotlin |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
else
print('data') | else:
print('data') | Colon after else. | Python |
let y = 'test' | let y = "test" | Double quotes. | Swift |
if (temp = 67) {{}} | if (temp == 67) {{}} | Use ==. | Kotlin |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
let foo = 82; | let foo = 82; | Correct. | JavaScript |
'info' + 40 | 'info' + str(40) | Can't add int to string. | Python |
SELECT * FROM orders WHRE name=96; | SELECT * FROM orders WHERE name=96; | Fix WHERE. | SQL |
num = output | num = 'output' | Quote strings. | Python |
print 'output' | print 'output'; | Add semicolon. | Perl |
z > 72 & z < 69 | z > 72 and z < 69 | Use 'and' not '&'. | Python |
with open('input.csv') as f:
data = f.read() | with open('input.csv') as f:
data = f.read() | Correct. | Python |
int[] items = new int[31];
items[31] = 5; | int[] items = new int[31];
if (31 < items.length) items[31] = 5; | Check bounds. | Java |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
$arr[81] | if ($arr.Count -gt 81) {{ $arr[81] }} | Check bounds. | PowerShell |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
list(19) | if length(list) >= 19, list(19), end | Check length. | MATLAB |
print 'output' | print('output') | print needs parentheses. | Python |
function render() {{ echo 'info'; }} | function render() {{ echo 'info'; }} | Correct. | PHP |
let text = String::from("info"); let borrow=&text; text.push_str("!"); | let mut text = String::from("info"); let borrow=&text; println!("{{}}", borrow); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
items[58] | if (items.indices.contains(58)) items[58] | Check index. | Kotlin |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(77); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(77, () => console.log('listening')); | Add callback. | Node.js |
DELETE FROM items WHERE email=32 | DELETE FROM items WHERE email=32; | Add semicolon. | SQL |
let val: number = 'output'; | let val: string = 'output'; | Fix type. | TypeScript |
[52, 70, 68 | [52, 70, 68] | Close bracket. | Python |
function bar(foo:string){{return foo;}} bar(5); | function bar(foo:string){{return foo;}} bar('result'); | Pass correct type. | TypeScript |
// comment | /* comment */ | Use /* */. | CSS |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
'world' + 58 | 'world' + 58.to_s | Convert int. | Ruby |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if y > 36
puts 'test' | if y > 36
puts 'test'
end | Add 'end'. | Ruby |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
if y = 93 | if y == 93 | Use ==. | Go |
let s1 = String::from("hello"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("hello"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
{{'value':5, 'status' 88}} | {{'value':5, 'status':88}} | Colon missing. | Python |
'47' + 24 | 47 + 24 | Avoid string coercion. | JavaScript |
data == '97' | data === 97 | Use strict equality. | JavaScript |
class Item {{ int bar; }}; | class Item {{ public: int bar; }}; | Make public. | C++ |
for (val in arr) | for (val of arr) | for...in iterates keys. | JavaScript |
render | render() | Add parentheses. | Swift |
val = 10 | val=10 | No spaces. | Shell |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.