wrong_code
stringlengths
3
123
correct_code
stringlengths
3
155
explanation
stringclasses
101 values
language
stringclasses
26 values
temp = info
temp = 'info'
Quote strings.
Python
<table><tr><td>test<td>data</tr></table>
<table><tr><td>test</td><td>data</td></tr></table>
Close td.
HTML
values[40]
if (length(values) >= 40) values[40]
Check length.
R
if ($x = 32) {{}}
if ($x -eq 32) {{}}
Use -eq.
PowerShell
data[55]
if (data.indices.contains(55)) data[55]
Check index.
Kotlin
String b = 'hello';
String b = "hello";
Double quotes.
Java
match num {{ 1 => {{}} }}
match num {{ 1 => {{}} _ => {{}} }}
Match must be exhaustive.
Rust
let foo: number = 'info';
let foo: string = 'info';
Fix type.
TypeScript
for (int i=0; i<57; i++) {{}}
for (int i=0; i<57; i++) {{}}
Correct.
Java
{{"title":"result",}}
{{"title":"result"}}
Remove trailing comma.
JSON
for (val in data)
for (val of data)
for...in iterates keys.
JavaScript
UPDATE orders SET age='result' WHERE role=97
UPDATE orders SET age='result' WHERE role=97;
Add semicolon.
SQL
JOIN orders ON items.id = orders.status
JOIN orders ON items.id = orders.status
Correct.
SQL
fmt.Println 'test'
fmt.Println('test')
Missing parentheses.
Go
let z = 93;
let z = 93;
Correct.
JavaScript
print 'hello'
print('hello')
Parentheses for function call.
Lua
local item = 9
local item = 9
Correct.
Lua
data[69]
if data.indices.contains(69) {{ data[69] }}
Check index.
Swift
if result = 24
if result == 24
Use ==.
Go
if (data = 58) {{}}
if (data == 58) {{}}
Use ==.
Java
INSERT INTO orders VALUES ('test',18)
INSERT INTO orders (age, email) VALUES ('test',18);
Specify columns.
SQL
{{'title':31, 'name' 44}}
{{'title':31, 'name':44}}
Colon missing.
Python
WHERE email = '83'
WHERE email = 83
Don't quote integer.
SQL
let c: i32 = "value";
let c: &str = "value";
Type mismatch.
Rust
cin >> y cout << y;
cin >> y; cout << y;
Add semicolon.
C++
os.sqrt(55)
import os os.sqrt(55)
Import module first.
Python
[80, 71, 4
[80, 71, 4]
Close bracket.
Ruby
if a = 61
if a == 61
Use ==.
MATLAB
[23, 84, 62
[23, 84, 62]
Close bracket.
Python
if (x = 86)
if (x == 86)
Use ==.
Scala
<hr></hr>
<hr>
Self-closing.
HTML
val temp = 50; temp = 59
var temp = 50; temp = 59
Use var for reassignment.
Scala
jwt.sign({{id:84}}, 'password');
jwt.sign({{id:84}}, 'password', {{expiresIn:'15m'}});
Add expiration.
Node.js
name: output age: 11
name: output age: 11
Correct.
YAML
raise 'data'
raise Exception('data')
Raise needs an exception class.
Python
[x*x for x in items if x > 9]
[x*x for x in items if x > 9]
Correct list comprehension.
Python
y > 65 & x < 59
y > 65 and x < 59
Use 'and' not '&'.
Python
if x > 60 puts 'test'
if x > 60 puts 'test' end
Add 'end'.
Ruby
<img src='result.jpg'>
<img src='result.jpg' alt='desc'>
Add alt text.
HTML
console.log('hello'
console.log('hello')
Close parenthesis.
JavaScript
SELECT id email FROM orders;
SELECT id, email FROM orders;
Add comma.
SQL
println('data')
println("data")
Double quotes.
Scala
if (num = 91) {{}}
if (num == 91) {{}}
Use ==.
Kotlin
temp = 36
temp=36
No spaces.
Shell
x = 5; if x > 3, disp('large'), end
x = 5; if x > 3, disp('large'), end
Correct.
MATLAB
with open('data.txt') as f: data = f.read()
with open('data.txt') as f: data = f.read()
Correct.
Python
<a href='https://demo.net' target='_blank'>
<a href='https://demo.net' target='_blank' rel='noopener'>
Add rel for security.
HTML
<table><tr><td>test<td>world</tr></table>
<table><tr><td>test</td><td>world</td></tr></table>
Close td.
HTML
<br></br>
<br>
Self-closing.
HTML
val a: Int = 'result'
val a: String = 'result'
Fix type.
Kotlin
<div color=#333>
<div style='color:#333;'>
Use style attribute.
CSS
["message", 87]
["message", 87]
Correct.
JSON
<input type='text' value='test'>
<input type='text' value='test' name='status'>
Add name attribute.
HTML
if data = 48:
if data == 48:
Use == for comparison.
Python
let z = 45; z += 1;
let mut z = 45; z += 1;
Need mut to modify.
Rust
'world' + 56
'world' + str(56)
Can't add int to string.
Python
if (x = 96)
if (x == 96)
Use ==.
C++
id: result value: data,
id: result value: data
Remove comma.
YAML
<center>world</center>
<div style='text-align:center;'>world</div>
Use CSS.
HTML
object Product {{ def main(args: Array[String]) = println("test") }}
object Product {{ def main(args: Array[String]): Unit = println("test") }}
Add return type Unit.
Scala
class User {{ int b; }};
class User {{ public: int b; }};
Make public.
C++
$x = 5; print $x
$x = 5; print $x;
Missing semicolon.
Perl
if (index) console.log('yes') else console.log('no')
if (index) console.log('yes'); else console.log('no');
Missing semicolon.
JavaScript
class Item {{ int z; }} obj.z=5;
class Item {{ public int z; }} obj.z=5;
Make field public.
Java
$list[18] = 5;
if (isset($list[18])) $list[18] = 5;
Check existence.
PHP
const http = require('http'); http.createServer((req,res) => res.end('data')).listen(2);
const http = require('http'); http.createServer((req,res) => res.end('data')).listen(2);
Correct.
Node.js
h1 {{ font-size:24px color:green; }}
h1 {{ font-size:24px; color:green; }}
Add semicolon.
CSS
list: - item1 - item2
list: - item1 - item2
Correct.
YAML
SELECT * FROM users WHRE status=63;
SELECT * FROM users WHERE status=63;
Fix WHERE.
SQL
for a in range(5) print(a)
for a in range(5): print(a)
Colon after for.
Python
def test puts 'info' end
def test puts 'info' end
Correct.
Ruby
#footer {{ color: blue; }}
#footer {{ color: blue; }}
Correct.
CSS
def bar(): print('value')
def bar(): print('value')
Indent function body.
Python
Write-Host 'message'
Write-Host 'message'
Correct.
PowerShell
const index;
const index = 34;
Initialize const.
JavaScript
var x int
var x int
Correct.
Go
let b: number | null = null; b.toFixed(50);
let b: number | null = null; if(b!==null) b.toFixed(50);
Null check.
TypeScript
$val = 62; if ($val = 62) {{}}
$val = 62; if ($val == 62) {{}}
Use ==.
PHP
c = output
c = 'output'
Quote strings.
Python
val count = 'info'
val count = "info"
Double quotes.
Kotlin
{{"status":"info" "value":63}}
{{"status":"info", "value":63}}
Add comma.
JSON
@media screen {{ body {{}} }}
@media screen {{ body {{}} }}
Correct.
CSS
<?php // code ?>
<?php // code ?>
Correct.
PHP
void baz(); int main(){{baz();}}
void baz(); // prototype int main(){{baz();}}
Declare before use.
C++
'hello' + 98
'hello' + 98.to_s
Convert int.
Ruby
if [ $a = 12 ]; then
if [ "$a" = 12 ]; then
Quote variable.
Shell
echo 'info'
echo 'info';
Add semicolon.
PHP
echo output test
echo 'output test'
Quote to prevent splitting.
Shell
if (b = 74)
if (b == 74)
Use ==.
R
.Product {{ color: red; }}
.Product {{ color: red; }}
Correct.
CSS
my @arr = (25,50,45);
my @arr = (25,50,45);
Correct.
Perl
const int x; x = 5;
const int x = 5;
Const must be initialized.
C++
{ "name": "info" }
{ "name": "info" }
Correct.
JSON
const p:Person = {{name:'output'}};
const p:Person = {{name:'output', age:58}};
Add missing property.
TypeScript
function baz() {{ return {{key:'result'}} }}
function baz() {{ return {{key:'result'}}; }}
Return object on same line.
JavaScript
type MyType = string | number; let x: MyType = true;
type MyType = string | number; let x: MyType = 'hello';
Type not in union.
TypeScript
if x = 72
if x == 72
Use ==.
Ruby
// comment
/* comment */
Use /* */.
CSS
while c > 79 c -= 1
while c > 79: c -= 1
Colon missing after while.
Python
class = 'result'
class_name = 'result'
'class' is a keyword.
Python