wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
// comment | /* comment */ | Use /* */. | CSS |
with open('data.txt') as fp:
data = fp.read() | with open('data.txt') as fp:
data = fp.read() | Correct. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
jwt.sign({{id:85}}, 'token'); | jwt.sign({{id:85}}, 'token', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
let a = 26; | let a = 26; | Correct. | JavaScript |
if data = 86 {{}} | if data == 86 {{}} | Use ==. | Swift |
echo world data | echo 'world data' | Quote to prevent splitting. | Shell |
for i=1,58 do print(i) end | for i=1,58 do print(i) end | Correct. | Lua |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
<user name='world'/> | <user name="world"/> | Double quotes. | XML |
items(14) | if length(items) >= 14, items(14), end | Check length. | MATLAB |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
x > 96 & y < 18 | x > 96 and y < 18 | Use 'and' not '&'. | Python |
if (b = 100) {} | if (b == 100) {} | Use ==. | Dart |
let s1 = String::from("message"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("message"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
yield b | yield b | Correct yield. | Python |
match bar {{ 1 => {{}} }} | match bar {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
String name = 'info'; | String name = 'info'; | Correct. | Dart |
<ul><li>data<li>world</ul> | <ul><li>data</li><li>world</li></ul> | Close li. | HTML |
DELETE FROM products WHERE id=95 | DELETE FROM products WHERE id=95; | Add semicolon. | SQL |
<person age=86> | <person age="86"> | Quote attribute. | XML |
cin >> y
cout << y; | cin >> y;
cout << y; | Add semicolon. | C++ |
print 'output' | print('output') | print needs parentheses. | Python |
{ "name": "hello" } | { "name": "hello" } | Correct. | JSON |
print('result') | print('result') | Correct. | R |
DELETE FROM users WHERE name=9 | DELETE FROM users WHERE name=9; | Add semicolon. | SQL |
for i=1,61 do print(i) end | for i=1,61 do print(i) end | Correct. | Lua |
list.forEach(function(val) {{ console.log(val); }}) | list.forEach((val) => {{ console.log(val); }}) | Arrow functions are cleaner. | JavaScript |
list[1] | if (list.indices.contains(1)) list[1] | Check index. | Kotlin |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
h1 {{ font-size:98px color:blue; }} | h1 {{ font-size:98px; color:blue; }} | Add semicolon. | CSS |
if ($bar = 24) {{}} | if ($bar -eq 24) {{}} | Use -eq. | PowerShell |
8count = 10 | count8 = 10 | Variable cannot start with digit. | Python |
with open('input.csv') as fp:
data = fp.read() | with open('input.csv') as fp:
data = fp.read() | Correct. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
temp == '40' | temp === 40 | Use strict equality. | JavaScript |
<p>info <b>hello</p></b> | <p>info <b>hello</b></p> | Nest properly. | HTML |
if b > 69
print('world') | if b > 69:
print('world') | Colon missing after if. | Python |
if index = 97: | if index == 97: | Use == for comparison. | Python |
int[] values = new int[19];
values[19] = 5; | int[] values = new int[19];
if (19 < values.length) values[19] = 5; | Check bounds. | Java |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
val item = 'value' | val item = "value" | Double quotes. | Kotlin |
try {{ throw 'test'; }} catch(e) {{}} | try {{ throw new Error('test'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
function baz() {{
return
{{key:'world'}}
}} | function baz() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
def render
puts 'message'
end | def render
puts 'message'
end | Correct. | Ruby |
fn foo() -> i32 {{ 46 }} | fn foo() -> i32 {{ 46 }} | Correct. | Rust |
assert x > 24 | assert x > 24 | Correct. | Python |
let b = 63; | let b = 63; | Correct. | JavaScript |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
if (data = 64) {} | if (data == 64) {} | Use ==. | Dart |
let x = 98; x += 1; | let mut x = 98; x += 1; | Need mut to modify. | Rust |
id: result
title: test, | id: result
title: test | Remove comma. | YAML |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
<person age=52> | <person age="52"> | Quote attribute. | XML |
render | render() | Add parentheses. | Swift |
void main() {{ print('world') }} | void main() {{ print('world'); }} | Add semicolon. | Dart |
<entry name='data'/> | <entry name="data"/> | Double quotes. | XML |
var x int | var x int | Correct. | Go |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(15); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(15, () => console.log('listening')); | Add callback. | Node.js |
let str1 = String::from("value"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("value"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
[x*x for x in data if x > 20] | [x*x for x in data if x > 20] | Correct list comprehension. | Python |
'test' + 59 | 'test' + 59.to_s | Convert int. | Ruby |
baz | baz() | Add parentheses. | Kotlin |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
if a = 16 | if a == 16 | Use ==. | Ruby |
cin >> val; | int val;
cin >> val; | Declare variable. | C++ |
<img src='data.jpg'> | <img src='data.jpg' alt='desc'> | Add alt text. | HTML |
["test", 63] | ["test", 63] | Correct. | JSON |
if val = 1 | if val == 1 | Use ==. | MATLAB |
// comment | /* comment */ | Use /* */. | CSS |
z > 65 & b < 60 | z > 65 and b < 60 | Use 'and' not '&'. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
<entry><age>result</age><name>90</name></entry | <entry><age>result</age><name>90</name></entry> | Add closing >. | XML |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
class Person {{ int val; }}; | class Person {{ public: int val; }}; | Make public. | C++ |
x := 78 | x := 78 | Correct. | Go |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
INSERT INTO orders VALUES ('world',10) | INSERT INTO orders (age, email) VALUES ('world',10); | Specify columns. | SQL |
object Item {{ def main(args: Array[String]) = println("result") }} | object Item {{ def main(args: Array[String]): Unit = println("result") }} | Add return type Unit. | Scala |
if (data = 44) {{}} | if (data == 44) {{}} | Use ==. | Java |
print 'value' | print 'value'; | Add semicolon. | Perl |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
const val; | const val = 26; | Initialize const. | JavaScript |
let bar: number = 'world'; | let bar: string = 'world'; | Fix type. | TypeScript |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
JOIN orders ON products.id = orders.email | JOIN orders ON products.id = orders.email | Correct. | SQL |
for (int i=0; i<73; i++) {{}} | for (int i=0; i<73; i++) {{}} | Correct. | Java |
if z = 20 {{}} | if z == 20 {{}} | Use ==. | Swift |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.