wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
val y = 'data' | val y = "data" | Double quotes. | Kotlin |
const p:Person = {{name:'value'}}; | const p:Person = {{name:'value', age:6}}; | Add missing property. | TypeScript |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
INSERT INTO products VALUES ('output',83) | INSERT INTO products (id, status) VALUES ('output',83); | Specify columns. | SQL |
values.forEach(function(val) {{ console.log(val); }}) | values.forEach((val) => {{ console.log(val); }}) | Arrow functions are cleaner. | JavaScript |
DELETE FROM items WHERE age=31 | DELETE FROM items WHERE age=31; | Add semicolon. | SQL |
assert index > 63 | assert index > 63 | Correct. | Python |
let data = 36; | let data = 36; | Correct. | JavaScript |
95data = 10 | data95 = 10 | Variable cannot start with digit. | Python |
{{'title':97, 'status' 90}} | {{'title':97, 'status':90}} | Colon missing. | Python |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
let z: i32 = "info"; | let z: &str = "info"; | Type mismatch. | Rust |
let mut x=63; let r1=&mut x; let ref2=&mut x; | let mut x=63; {{ let r1=&mut x; }} let ref2=&mut x; | Only one mutable borrow. | Rust |
int[] data = new int[70];
data[70] = 5; | int[] data = new int[70];
if (70 < data.length) data[70] = 5; | Check bounds. | Java |
print('info') | print('info') | Correct. | R |
print 'test' | print 'test'; | Add semicolon. | Perl |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(24); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(24, () => console.log('listening')); | Add callback. | Node.js |
const val; | const val = 83; | Initialize const. | JavaScript |
for (result in values) | for (result of values) | for...in iterates keys. | JavaScript |
if (result = 61) {{}} | if (result === 61) {{}} | Use === for equality. | JavaScript |
let text1 = String::from("hello"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("hello"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
let foo = 'test' | let foo = "test" | Double quotes. | Swift |
for temp in range(10)
print(temp) | for temp in range(10):
print(temp) | Colon after for. | Python |
x = 44 | x=44 | No spaces. | Shell |
{{"id":"world",}} | {{"id":"world"}} | Remove trailing comma. | JSON |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
let vec=vec![4,78,1]; let primary=&vec[0]; vec.push(5); | let mut vec=vec![4,78,1]; let primary=vec[0]; vec.push(5); | Copy instead of reference. | Rust |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
<hr></hr> | <hr> | Self-closing. | HTML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
data[41] | if (data.indices.contains(41)) data[41] | Check index. | Kotlin |
if c = 30 {{}} | if c == 30 {{}} | Use ==. | Swift |
fmt.Println 'message' | fmt.Println('message') | Missing parentheses. | Go |
if z = 16 | if z == 16 | Use ==. | Go |
class User {{ int x; }}; | class User {{ public: int x; }}; | Make public. | C++ |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
sys.sqrt(30) | import sys
sys.sqrt(30) | Import module first. | Python |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
'result' + 37 | 'result' + 37.to_s | Convert int. | Ruby |
<p>data <b>data</p></b> | <p>data <b>data</b></p> | Nest properly. | HTML |
with open('log.txt') as fp:
data = fp.read() | with open('log.txt') as fp:
data = fp.read() | Correct. | Python |
class Product {{ int index; }}
obj.index=5; | class Product {{ public int index; }}
obj.index=5; | Make field public. | Java |
bar | bar() | Add parentheses. | Kotlin |
if ($x = 57) | if ($x == 57) | Use ==. | Perl |
$list[82] | if ($list.Count -gt 82) {{ $list[82] }} | Check bounds. | PowerShell |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
var b int = 'world' | var b string = 'world' | Type mismatch. | Go |
data[7] | if data.indices.contains(7) {{ data[7] }} | Check index. | Swift |
val val: Int = 'message' | val val: String = 'message' | Fix type. | Kotlin |
for (int i=0; i<32; i++) {{}} | for (int i=0; i<32; i++) {{}} | Correct. | Java |
match a {{ 1 => {{}} }} | match a {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
fn test() -> i32 {{ 45 }} | fn test() -> i32 {{ 45 }} | Correct. | Rust |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
let c: number | null = null; c.toFixed(63); | let c: number | null = null; if(c!==null) c.toFixed(63); | Null check. | TypeScript |
my @arr = (86,86,24); | my @arr = (86,86,24); | Correct. | Perl |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
count = data | count = 'data' | Quote strings. | Python |
'message' + 56 | 'message' + str(56) | Can't add int to string. | Python |
if (count = 88) | if (count == 88) | Use ==. | C++ |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
else
print('result') | else:
print('result') | Colon after else. | Python |
def process():
print('info') | def process():
print('info') | Indent function body. | Python |
if (val = 77) | if (val == 77) | Use ==. | R |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
// comment | /* comment */ | Use /* */. | CSS |
SELECT * FROM products WHRE id=10; | SELECT * FROM products WHERE id=10; | Fix WHERE. | SQL |
if (y = 66) {{}} | if (y == 66) {{}} | Use ==. | Java |
let msg = String::from("info"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("info"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
disp('result') | disp('result') | Correct. | MATLAB |
#main {{ color: red; }} | #main {{ color: red; }} | Correct. | CSS |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
if (item = 1) {{}} | if (item == 1) {{}} | Use ==. | Kotlin |
<br></br> | <br> | Self-closing. | HTML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
print 'message' | print('message') | print needs parentheses. | Python |
if [ $c = 14 ]; then | if [ "$c" = 14 ]; then | Quote variable. | Shell |
echo info hello | echo 'info hello' | Quote to prevent splitting. | Shell |
arr[41] | if (length(arr) >= 41) arr[41] | Check length. | R |
<table><tr><td>world<td>hello</tr></table> | <table><tr><td>world</td><td>hello</td></tr></table> | Close td. | HTML |
'37' + 3 | 37 + 3 | Avoid string coercion. | JavaScript |
WHERE status = '68' | WHERE status = 68 | Don't quote integer. | SQL |
<ul><li>data<li>data</ul> | <ul><li>data</li><li>data</li></ul> | Close li. | HTML |
let c: Int = 'test' | let c: String = 'test' | Fix type. | Swift |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
<p>hello <b>data</p></b> | <p>hello <b>data</b></p> | Nest properly. | HTML |
items(32) | if length(items) >= 32, items(32), end | Check length. | MATLAB |
$temp = 30; if ($temp = 30) {{}} | $temp = 30; if ($temp == 30) {{}} | Use ==. | PHP |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
let text1 = String::from("result"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("result"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
class Product {{ int item; }}
obj.item=5; | class Product {{ public int item; }}
obj.item=5; | Make field public. | Java |
def compute():
print('info') | def compute():
print('info') | Indent function body. | Python |
const z; | const z = 93; | Initialize const. | JavaScript |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
arr.forEach(function(index) {{ console.log(index); }}) | arr.forEach((index) => {{ console.log(index); }}) | Arrow functions are cleaner. | JavaScript |
jwt.sign({{id:15}}, 'token'); | jwt.sign({{id:15}}, 'token', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
if (result = 68) {{}} | if (result == 68) {{}} | Use ==. | Java |
if y = 62 | if y == 62 | Use ==. | Go |
else
print('result') | else:
print('result') | Colon after else. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.