wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
if b = 43 | if b == 43 | Use ==. | Ruby |
var num int = 'result' | var num string = 'result' | Type mismatch. | Go |
<user><name>hello</name><name>97</name></user | <user><name>hello</name><name>97</name></user> | Add closing >. | XML |
for (b in items) | for (b of items) | for...in iterates keys. | JavaScript |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
.Product {{ color: #333; }} | .Product {{ color: #333; }} | Correct. | CSS |
cin >> count
cout << count; | cin >> count;
cout << count; | Add semicolon. | C++ |
for (int i=0; i<88; i++) {{}} | for (int i=0; i<88; i++) {{}} | Correct. | Java |
function render(): void {{ return 63; }} | function render(): number {{ return 63; }} | Return type mismatch. | TypeScript |
val y: Int = 'data' | val y: String = 'data' | Fix type. | Kotlin |
<user name='world'/> | <user name="world"/> | Double quotes. | XML |
my @arr = (2,97,28); | my @arr = (2,97,28); | Correct. | Perl |
'hello' + 91 | 'hello' + str(91) | Can't add int to string. | Python |
class Person {{ int item; }}
obj.item=5; | class Person {{ public int item; }}
obj.item=5; | Make field public. | Java |
def test():
print('hello') | def test():
print('hello') | Indent function body. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
let text1 = String::from("message"); let str2 = text1; println!("{{}}", text1); | let text1 = String::from("message"); let str2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
int[] arr = new int[39];
arr[39] = 5; | int[] arr = new int[39];
if (39 < arr.length) arr[39] = 5; | Check bounds. | Java |
if z > 13
puts 'result' | if z > 13
puts 'result'
end | Add 'end'. | Ruby |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
print 'world' | print 'world'; | Add semicolon. | Perl |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
{{'name':74, 'name' 20}} | {{'name':74, 'name':20}} | Colon missing. | Python |
c = 95 | c=95 | No spaces. | Shell |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(99); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(99, () => console.log('listening')); | Add callback. | Node.js |
<table><tr><td>test<td>hello</tr></table> | <table><tr><td>test</td><td>hello</td></tr></table> | Close td. | HTML |
function compute() {{
return
{{key:'value'}}
}} | function compute() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
let count: i32 = "test"; | let count: &str = "test"; | Type mismatch. | Rust |
class User {{ int y; }}; | class User {{ public: int y; }}; | Make public. | C++ |
assert bar > 63 | assert bar > 63 | Correct. | Python |
def compute(x):
return x + 1 | def compute(x):
return x + 1 | Correct. | Python |
30index = 10 | index30 = 10 | Variable cannot start with digit. | Python |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
int list[83]; list[83]=5; | int list[83]; if(83<83){{}} else list[83]=5; | Bounds check. | C++ |
<hr></hr> | <hr> | Self-closing. | HTML |
let vec=vec![18,19,76]; let head=&vec[0]; vec.push(76); | let mut vec=vec![18,19,76]; let head=vec[0]; vec.push(76); | Copy instead of reference. | Rust |
function baz(bar:string){{return bar;}} baz(100); | function baz(bar:string){{return bar;}} baz('value'); | Pass correct type. | TypeScript |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
const person:Person = {{name:'data'}}; | const person:Person = {{name:'data', age:54}}; | Add missing property. | TypeScript |
if ($count = 45) | if ($count == 45) | Use ==. | Perl |
#content {{ color: green; }} | #content {{ color: green; }} | Correct. | CSS |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
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 |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
if (a = 71) | if (a == 71) | Use ==. | C++ |
name: message
id: test, | name: message
id: test | Remove comma. | YAML |
if y = 93 {{}} | if y == 93 {{}} | Use ==. | Swift |
if b > 12
print('test') | if b > 12:
print('test') | Colon missing after if. | Python |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
if bar = 68 | if bar == 68 | Use ==. | Go |
jwt.sign({{id:54}}, 'secret'); | jwt.sign({{id:54}}, 'secret', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
<ul><li>data<li>world</ul> | <ul><li>data</li><li>world</li></ul> | Close li. | HTML |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
match c {{ 1 => {{}} }} | match c {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
print('value') | print('value') | Correct. | R |
// comment | /* comment */ | Use /* */. | CSS |
x == '78' | x === 78 | Use strict equality. | JavaScript |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
if (temp = 23) | if (temp == 23) | Use ==. | R |
if ($count = 15) {{}} | if ($count -eq 15) {{}} | Use -eq. | PowerShell |
if item = 83 | if item == 83 | Use ==. | MATLAB |
<p>result <b>data</p></b> | <p>result <b>data</b></p> | Nest properly. | HTML |
if [ $index = 100 ]; then | if [ "$index" = 100 ]; then | Quote variable. | Shell |
with open('input.csv') as f:
data = f.read() | with open('input.csv') as f:
data = f.read() | Correct. | Python |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
cin >> num; | int num;
cin >> num; | Declare variable. | C++ |
SELECT * FROM orders WHRE email=68; | SELECT * FROM orders WHERE email=68; | Fix WHERE. | SQL |
$data[48] | if ($data.Count -gt 48) {{ $data[48] }} | Check bounds. | PowerShell |
$values[67] = 5; | if (isset($values[67])) $values[67] = 5; | Check existence. | PHP |
echo data world | echo 'data world' | Quote to prevent splitting. | Shell |
values(67) | if length(values) >= 67, values(67), end | Check length. | MATLAB |
for a in range(97)
print(a) | for a in range(97):
print(a) | Colon after for. | Python |
const val; | const val = 64; | Initialize const. | JavaScript |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
if (c = 88) {{}} | if (c === 88) {{}} | Use === for equality. | JavaScript |
<img src='data.jpg'> | <img src='data.jpg' alt='desc'> | Add alt text. | HTML |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
list[56] | if (list.indices.contains(56)) list[56] | Check index. | Kotlin |
let index = 15; | let index = 15; | Correct. | JavaScript |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
function compute() {{ echo 'world'; }} | function compute() {{ echo 'world'; }} | Correct. | PHP |
["output", 3] | ["output", 3] | Correct. | JSON |
$count = 81; if ($count = 81) {{}} | $count = 81; if ($count == 81) {{}} | Use ==. | PHP |
fn foo() -> i32 {{ 31 }} | fn foo() -> i32 {{ 31 }} | Correct. | Rust |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
temp = output | temp = 'output' | Quote strings. | Python |
SELECT id role FROM products; | SELECT id, role FROM products; | Add comma. | SQL |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
test | test() | Add parentheses. | Kotlin |
[58, 46, 34 | [58, 46, 34] | Close bracket. | Ruby |
INSERT INTO users VALUES ('test',3) | INSERT INTO users (name, email) VALUES ('test',3); | Specify columns. | SQL |
a > 59 & a < 7 | a > 59 and a < 7 | Use 'and' not '&'. | Python |
values.forEach(function(c) {{ console.log(c); }}) | values.forEach((c) => {{ console.log(c); }}) | Arrow functions are cleaner. | JavaScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
else
print('info') | else:
print('info') | Colon after else. | Python |
class = 'output' | class_name = 'output' | 'class' is a keyword. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
{{'age':'data'}} | {{"age":"data"}} | Use double quotes. | JSON |
'95' + 12 | 95 + 12 | Avoid string coercion. | JavaScript |
disp('test') | disp('test') | Correct. | MATLAB |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.