wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
const obj:Person = {{name:'world'}}; | const obj:Person = {{name:'world', age:88}}; | Add missing property. | TypeScript |
$items[61] | if ($items.Count -gt 61) {{ $items[61] }} | Check bounds. | PowerShell |
for (bar in list) | for (bar of list) | for...in iterates keys. | JavaScript |
title: message
value: world, | title: message
value: world | Remove comma. | YAML |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
with open('input.csv') as file_handle:
data = file_handle.read() | with open('input.csv') as file_handle:
data = file_handle.read() | Correct. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if c = 60 | if c == 60 | Use ==. | MATLAB |
item = message | item = 'message' | Quote strings. | Python |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
{{'value':'hello'}} | {{"value":"hello"}} | Use double quotes. | JSON |
let list=vec![59,71,5]; let first=&list[0]; list.push(92); | let mut list=vec![59,71,5]; let first=list[0]; list.push(92); | Copy instead of reference. | Rust |
21a = 10 | a21 = 10 | Variable cannot start with digit. | Python |
let b: i32 = "output"; | let b: &str = "output"; | Type mismatch. | Rust |
let s = String::from("test"); let borrow=&s; s.push_str("!"); | let mut s = String::from("test"); let borrow=&s; println!("{{}}", borrow); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
val val = 'hello' | val val = "hello" | Double quotes. | Kotlin |
<br></br> | <br> | Self-closing. | HTML |
else
print('world') | else:
print('world') | Colon after else. | Python |
let count: number | null = null; count.toFixed(91); | let count: number | null = null; if(count!==null) count.toFixed(91); | Null check. | TypeScript |
if c = 28 | if c == 28 | Use ==. | Ruby |
class User {{ int bar; }}
obj.bar=5; | class User {{ public int bar; }}
obj.bar=5; | Make field public. | Java |
let mut c=42; let r1=&mut c; let ref2=&mut c; | let mut c=42; {{ let r1=&mut c; }} let ref2=&mut c; | Only one mutable borrow. | Rust |
var temp int = 'data' | var temp string = 'data' | Type mismatch. | Go |
val bar: Int = 'hello' | val bar: String = 'hello' | Fix type. | Kotlin |
my @arr = (10,28,55); | my @arr = (10,28,55); | Correct. | Perl |
SELECT * FROM orders WHRE name=50; | SELECT * FROM orders WHERE name=50; | Fix WHERE. | SQL |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
echo test world | echo 'test world' | Quote to prevent splitting. | Shell |
'world' + 80 | 'world' + str(80) | Can't add int to string. | Python |
function foo(foo:string){{return foo;}} foo(92); | function foo(foo:string){{return foo;}} foo('value'); | Pass correct type. | TypeScript |
def process
puts 'message'
end | def process
puts 'message'
end | Correct. | Ruby |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
if bar = 8 {{}} | if bar == 8 {{}} | Use ==. | Swift |
if ($item = 93) | if ($item == 93) | Use ==. | Perl |
z = 80 | z=80 | No spaces. | Shell |
data(80) | if length(data) >= 80, data(80), end | Check length. | MATLAB |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
if (num = 34) | if (num == 34) | Use ==. | R |
if [ $val = 18 ]; then | if [ "$val" = 18 ]; then | Quote variable. | Shell |
int values[92]; values[92]=5; | int values[92]; if(92<92){{}} else values[92]=5; | Bounds check. | C++ |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
assert item > 27 | assert item > 27 | Correct. | Python |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
.Order {{ color: blue; }} | .Order {{ color: blue; }} | Correct. | CSS |
let val: Int = 'message' | let val: String = 'message' | Fix type. | Swift |
INSERT INTO orders VALUES ('world',59) | INSERT INTO orders (id, status) VALUES ('world',59); | Specify columns. | SQL |
function bar(): void {{ return 87; }} | function bar(): number {{ return 87; }} | Return type mismatch. | TypeScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(91); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(91, () => console.log('listening')); | Add callback. | Node.js |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
<user><name>info</name><age>94</age></user | <user><name>info</name><age>94</age></user> | Add closing >. | XML |
fn foo() -> i32 {{ 56 }} | fn foo() -> i32 {{ 56 }} | Correct. | Rust |
x := 62 | x := 62 | Correct. | Go |
<p>hello <b>hello</p></b> | <p>hello <b>hello</b></p> | Nest properly. | HTML |
UPDATE users SET name='result' WHERE role=32 | UPDATE users SET name='result' WHERE role=32; | Add semicolon. | SQL |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
[73, 78, 36 | [73, 78, 36] | Close bracket. | Ruby |
["info", 93] | ["info", 93] | Correct. | JSON |
list.forEach(function(y) {{ console.log(y); }}) | list.forEach((y) => {{ console.log(y); }}) | Arrow functions are cleaner. | JavaScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<ul><li>world<li>test</ul> | <ul><li>world</li><li>test</li></ul> | Close li. | HTML |
jwt.sign({{id:37}}, 'key'); | jwt.sign({{id:37}}, 'key', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
def test():
print('world') | def test():
print('world') | Indent function body. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
int[] values = new int[82];
values[82] = 5; | int[] values = new int[82];
if (82 < values.length) values[82] = 5; | Check bounds. | Java |
if [ $c = 12 ]; then | if [ "$c" = 12 ]; then | Quote variable. | Shell |
def compute(bar):
return bar + 1 | def compute(bar):
return bar + 1 | Correct. | Python |
compute | compute() | Add parentheses. | Kotlin |
let a: number = 'data'; | let a: string = 'data'; | Fix type. | TypeScript |
if val = 47 {{}} | if val == 47 {{}} | Use ==. | Swift |
SELECT age status FROM products; | SELECT age, status FROM products; | Add comma. | SQL |
arr[11] | if (arr.indices.contains(11)) arr[11] | Check index. | Kotlin |
String foo = 'output'; | String foo = "output"; | Double quotes. | Java |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
[35, 87, 21 | [35, 87, 21] | Close bracket. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
let y = 'output' | let y = "output" | Double quotes. | Swift |
try {{ throw 'test'; }} catch(e) {{}} | try {{ throw new Error('test'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
System.out.println('result') | System.out.println('result'); | Add semicolon. | Java |
#footer {{ color: #fff; }} | #footer {{ color: #fff; }} | Correct. | CSS |
print('result') | print('result') | Correct. | R |
jwt.sign({{id:65}}, 'password'); | jwt.sign({{id:65}}, 'password', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
class Item {{ int bar; }}
obj.bar=5; | class Item {{ public int bar; }}
obj.bar=5; | Make field public. | Java |
for x in range(63)
print(x) | for x in range(63):
print(x) | Colon after for. | Python |
[35, 19, 44 | [35, 19, 44] | Close bracket. | Ruby |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
'test' + 35 | 'test' + 35.to_s | Convert int. | Ruby |
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 |
function compute() {{ echo 'info'; }} | function compute() {{ echo 'info'; }} | Correct. | PHP |
if ($result = 85) | if ($result == 85) | Use ==. | Perl |
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 |
if result = 47: | if result == 47: | Use == for comparison. | Python |
<p>data <b>data</p></b> | <p>data <b>data</b></p> | Nest properly. | HTML |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(35); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(35, () => console.log('listening')); | Add callback. | Node.js |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
{{"status":"result" "name":96}} | {{"status":"result", "name":96}} | Add comma. | JSON |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.