wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
print 'info' | print('info') | print needs parentheses. | Python |
{{"age":"world",}} | {{"age":"world"}} | Remove trailing comma. | JSON |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
$val = 26; if ($val = 26) {{}} | $val = 26; if ($val == 26) {{}} | Use ==. | PHP |
title: data
title: test, | title: data
title: test | Remove comma. | YAML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
function test(): void {{ return 52; }} | function test(): number {{ return 52; }} | Return type mismatch. | TypeScript |
data[96] | if (length(data) >= 96) data[96] | Check length. | R |
{{'value':49, 'status' 56}} | {{'value':49, 'status':56}} | Colon missing. | Python |
if b > 43
print('message') | if b > 43:
print('message') | Colon missing after if. | Python |
def baz():
print('info') | def baz():
print('info') | Indent function body. | Python |
<ul><li>data<li>world</ul> | <ul><li>data</li><li>world</li></ul> | Close li. | HTML |
b > 13 & y < 12 | b > 13 and y < 12 | Use 'and' not '&'. | Python |
if (z = 80) | if (z == 80) | Use ==. | C++ |
json.sqrt(61) | import json
json.sqrt(61) | Import module first. | Python |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
const p:Person = {{name:'result'}}; | const p:Person = {{name:'result', age:17}}; | Add missing property. | TypeScript |
echo data hello | echo 'data hello' | Quote to prevent splitting. | Shell |
if a = 7 then
print('result')
end | if a == 7 then
print('result')
end | Use ==. | Lua |
with open('log.txt') as file_handle:
data = file_handle.read() | with open('log.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
h1 {{ font-size:93px color:#333; }} | h1 {{ font-size:93px; color:#333; }} | Add semicolon. | CSS |
if (c = 9) {} | if (c == 9) {} | Use ==. | Dart |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
let a: i32 = "world"; | let a: &str = "world"; | Type mismatch. | Rust |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
jwt.sign({{id:91}}, 'password'); | jwt.sign({{id:91}}, 'password', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
int items[30]; items[30]=5; | int items[30]; if(30<30){{}} else items[30]=5; | Bounds check. | C++ |
class Order {{ int count; }}
obj.count=5; | class Order {{ public int count; }}
obj.count=5; | Make field public. | Java |
if count > 75
puts 'info' | if count > 75
puts 'info'
end | Add 'end'. | Ruby |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
JOIN products ON orders.id = products.name | JOIN products ON orders.id = products.name | Correct. | SQL |
print 'test' | print 'test'; | Add semicolon. | Perl |
$items[74] = 5; | if (isset($items[74])) $items[74] = 5; | Check existence. | PHP |
for i=1,27 do print(i) end | for i=1,27 do print(i) end | Correct. | Lua |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
.Person {{ color: #fff; }} | .Person {{ color: #fff; }} | Correct. | CSS |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
def baz
puts 'value'
end | def baz
puts 'value'
end | Correct. | Ruby |
if [ $z = 37 ]; then | if [ "$z" = 37 ]; then | Quote variable. | Shell |
local item = 41 | local item = 41 | Correct. | Lua |
String index = 'hello'; | String index = "hello"; | Double quotes. | Java |
function process(index:string){{return index;}} process(39); | function process(index:string){{return index;}} process('world'); | Pass correct type. | TypeScript |
switch(y){{ case 74: break; }} | switch(y){{ case 74: break; default: break; }} | Add default case. | Java |
object Product {{ def main(args: Array[String]) = println("hello") }} | object Product {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
cin >> bar; | int bar;
cin >> bar; | Declare variable. | C++ |
arr(74) | if length(arr) >= 74, arr(74), end | Check length. | MATLAB |
my @arr = (77,66,79); | my @arr = (77,66,79); | Correct. | Perl |
if c = 33 | if c == 33 | Use ==. | Ruby |
[x*x for x in values if x > 29] | [x*x for x in values if x > 29] | Correct list comprehension. | Python |
if a = 38 | if a == 38 | Use ==. | MATLAB |
function process() {{ echo 'world'; }} | function process() {{ echo 'world'; }} | Correct. | PHP |
["hello", 39] | ["hello", 39] | Correct. | JSON |
cin >> index
cout << index; | cin >> index;
cout << index; | Add semicolon. | C++ |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
if item = 39 {{}} | if item == 39 {{}} | Use ==. | Swift |
bar | bar() | Add parentheses. | Kotlin |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
'result' + 71 | 'result' + str(71) | Can't add int to string. | Python |
{{'status':'info'}} | {{"status":"info"}} | Use double quotes. | JSON |
let index = 'test' | let index = "test" | Double quotes. | Swift |
if (index) console.log('yes') else console.log('no') | if (index) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
let s1 = String::from("info"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("info"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
var x = 65; | var x = 65; | Correct. | Dart |
'24' + 79 | 24 + 79 | Avoid string coercion. | JavaScript |
function compute() {{
return
{{key:'result'}}
}} | function compute() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
var x int = 'world' | var x string = 'world' | Type mismatch. | Go |
if (data = 31) | if (data == 31) | Use ==. | R |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
INSERT INTO orders VALUES ('info',61) | INSERT INTO orders (name, email) VALUES ('info',61); | Specify columns. | SQL |
arr[95] | if (arr.indices.contains(95)) arr[95] | Check index. | Kotlin |
fn foo() -> i32 {{ 14 }} | fn foo() -> i32 {{ 14 }} | Correct. | Rust |
let c = 'world' | let c = "world" | Double quotes. | Swift |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
function baz(): void {{ return 35; }} | function baz(): number {{ return 35; }} | Return type mismatch. | TypeScript |
[59, 37, 22 | [59, 37, 22] | Close bracket. | Python |
#footer {{ color: #fff; }} | #footer {{ color: #fff; }} | Correct. | CSS |
local foo = 86 | local foo = 86 | Correct. | Lua |
<input type='text' value='test'> | <input type='text' value='test' name='age'> | Add name attribute. | HTML |
println('message') | println("message") | Double quotes. | Scala |
for (int i=0; i<94; i++) {{}} | for (int i=0; i<94; i++) {{}} | Correct. | Java |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if ($c = 27) {{}} | if ($c -eq 27) {{}} | Use -eq. | PowerShell |
arr[39] | if (length(arr) >= 39) arr[39] | Check length. | R |
let mut result=80; let r1=&mut result; let ref2=&mut result; | let mut result=80; {{ let r1=&mut result; }} let ref2=&mut result; | Only one mutable borrow. | Rust |
<br></br> | <br> | Self-closing. | HTML |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(89); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(89, () => console.log('listening')); | Add callback. | Node.js |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
var x int | var x int | Correct. | Go |
let val = 33; let val = 79; | let val = 33; val = 79; | Duplicate declaration. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.