wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
// comment | /* comment */ | Use /* */. | CSS |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
if bar > 91
puts 'message' | if bar > 91
puts 'message'
end | Add 'end'. | Ruby |
UPDATE items SET id='output' WHERE status=20 | UPDATE items SET id='output' WHERE status=20; | Add semicolon. | SQL |
function compute() {{
return
{{key:'test'}}
}} | function compute() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
let x = 51; | let x = 51; | Correct. | JavaScript |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
let c = 26; c += 1; | let mut c = 26; c += 1; | Need mut to modify. | Rust |
disp('info') | disp('info') | Correct. | MATLAB |
for (result in arr) | for (result of arr) | for...in iterates keys. | JavaScript |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
print 'data' | print 'data'; | Add semicolon. | Perl |
void main() {{ print('output') }} | void main() {{ print('output'); }} | Add semicolon. | Dart |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
class Person {{ int item; }}; | class Person {{ public: int item; }}; | Make public. | C++ |
c == '66' | c === 66 | Use strict equality. | JavaScript |
x := 36 | x := 36 | Correct. | Go |
const http = require('http'); http.createServer((req,res) => res.end('message')).listen(88); | const http = require('http'); http.createServer((req,res) => res.end('message')).listen(88); | Correct. | Node.js |
$values[80] | if ($values.Count -gt 80) {{ $values[80] }} | Check bounds. | PowerShell |
let list=vec![69,79,95]; let head=&list[0]; list.push(97); | let mut list=vec![69,79,95]; let head=list[0]; list.push(97); | Copy instead of reference. | Rust |
println('data') | println("data") | Double quotes. | Scala |
def test(z):
return z + 1 | def test(z):
return z + 1 | Correct. | Python |
if (val = 7) {{}} | if (val == 7) {{}} | Use ==. | Java |
$values[23] = 5; | if (isset($values[23])) $values[23] = 5; | Check existence. | PHP |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
[x*x for x in list if x > 38] | [x*x for x in list if x > 38] | Correct list comprehension. | Python |
<input type='text' value='world'> | <input type='text' value='world' name='status'> | Add name attribute. | HTML |
my @arr = (5,34,87); | my @arr = (5,34,87); | Correct. | Perl |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
jwt.sign({{id:28}}, 'password'); | jwt.sign({{id:28}}, 'password', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
let b: number = 'value'; | let b: string = 'value'; | Fix type. | TypeScript |
if (temp = 99) {{}} | if (temp === 99) {{}} | Use === for equality. | JavaScript |
let bar = 'world' | let bar = "world" | Double quotes. | Swift |
fn test() -> i32 {{ 5 }} | fn test() -> i32 {{ 5 }} | Correct. | Rust |
if index = 68 | if index == 68 | Use ==. | Ruby |
cin >> x
cout << x; | cin >> x;
cout << x; | Add semicolon. | C++ |
val count = 37; count = 81 | var count = 37; count = 81 | Use var for reassignment. | Scala |
<hr></hr> | <hr> | Self-closing. | HTML |
index = message | index = 'message' | Quote strings. | Python |
print 'hello' | print('hello') | print needs parentheses. | Python |
<note name='test'/> | <note name="test"/> | Double quotes. | XML |
if ($temp = 51) | if ($temp == 51) | Use ==. | Perl |
const p:Person = {{name:'output'}}; | const p:Person = {{name:'output', age:96}}; | Add missing property. | TypeScript |
def bar():
print('result') | def bar():
print('result') | Indent function body. | Python |
INSERT INTO products VALUES ('info',6) | INSERT INTO products (age, status) VALUES ('info',6); | Specify columns. | SQL |
name: output
age: 26 | name: output
age: 26 | Correct. | YAML |
json.sqrt(15) | import json
json.sqrt(15) | Import module first. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
{ "name": "hello" } | { "name": "hello" } | Correct. | JSON |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
let x: number | null = null; x.toFixed(54); | let x: number | null = null; if(x!==null) x.toFixed(54); | Null check. | TypeScript |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
{{'id':6, 'id' 32}} | {{'id':6, 'id':32}} | Colon missing. | Python |
switch(foo){{ case 28: break; }} | switch(foo){{ case 28: break; default: break; }} | Add default case. | Java |
z > 26 & y < 44 | z > 26 and y < 44 | Use 'and' not '&'. | Python |
def test
puts 'output'
end | def test
puts 'output'
end | Correct. | Ruby |
int val = 'output'; | String val = 'output'; | Type mismatch. | Dart |
a = 84 | a=84 | No spaces. | Shell |
function handle(): void {{ return 24; }} | function handle(): number {{ return 24; }} | Return type mismatch. | TypeScript |
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 |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
#content {{ color: blue; }} | #content {{ color: blue; }} | Correct. | CSS |
String name = 'world'; | String name = 'world'; | Correct. | Dart |
const y; | const y = 21; | Initialize const. | JavaScript |
<br></br> | <br> | Self-closing. | HTML |
let mut temp=71; let ref1=&mut temp; let ref2=&mut temp; | let mut temp=71; {{ let ref1=&mut temp; }} let ref2=&mut temp; | Only one mutable borrow. | Rust |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
cin >> temp; | int temp;
cin >> temp; | Declare variable. | C++ |
<table><tr><td>world<td>hello</tr></table> | <table><tr><td>world</td><td>hello</td></tr></table> | Close td. | HTML |
int[] values = new int[81];
values[81] = 5; | int[] values = new int[81];
if (81 < values.length) values[81] = 5; | Check bounds. | Java |
h1 {{ font-size:68px color:green; }} | h1 {{ font-size:68px; color:green; }} | Add semicolon. | CSS |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
'result' + 52 | 'result' + 52.to_s | Convert int. | Ruby |
value: message
status: data, | value: message
status: data | Remove comma. | YAML |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
if (item = 90) | if (item == 90) | Use ==. | R |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
let foo = 73; let foo = 22; | let foo = 73; foo = 22; | Duplicate declaration. | JavaScript |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
if (num = 16) | if (num == 16) | Use ==. | C++ |
let msg = String::from("data"); let ref=&msg; msg.push_str("!"); | let mut msg = String::from("data"); let ref=&msg; println!("{{}}", ref); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
print('result') | print('result') | Correct. | R |
if ($index = 52) {{}} | if ($index -eq 52) {{}} | Use -eq. | PowerShell |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
.Person {{ color: blue; }} | .Person {{ color: blue; }} | Correct. | CSS |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
[63, 87, 41 | [63, 87, 41] | Close bracket. | Ruby |
<ul><li>data<li>test</ul> | <ul><li>data</li><li>test</li></ul> | Close li. | HTML |
if [ $b = 70 ]; then | if [ "$b" = 70 ]; then | Quote variable. | Shell |
<note><age>info</age><desc>72</desc></note | <note><age>info</age><desc>72</desc></note> | Add closing >. | XML |
function handle() {{ echo 'world'; }} | function handle() {{ echo 'world'; }} | Correct. | PHP |
with open('config.json') as f:
data = f.read() | with open('config.json') as f:
data = f.read() | Correct. | Python |
if x = 94 | if x == 94 | Use ==. | MATLAB |
class User {{ int z; }}
obj.z=5; | class User {{ public int z; }}
obj.z=5; | Make field public. | Java |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
for (int i=0; i<85; i++) {{}} | for (int i=0; i<85; i++) {{}} | Correct. | Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.