wrong_code
stringlengths
3
123
correct_code
stringlengths
3
155
explanation
stringclasses
101 values
language
stringclasses
26 values
<user name='output'/>
<user name="output"/>
Double quotes.
XML
else print('info')
else: print('info')
Colon after else.
Python
var x int
var x int
Correct.
Go
let bar: number = 'data';
let bar: string = 'data';
Fix type.
TypeScript
for i=1,13 do print(i) end
for i=1,13 do print(i) end
Correct.
Lua
<root><child>text</child></root>
<root><child>text</child></root>
Correct.
XML
h1 {{ font-size:9px color:red; }}
h1 {{ font-size:9px; color:red; }}
Add semicolon.
CSS
raise 'result'
raise Exception('result')
Raise needs an exception class.
Python
if ($result = 57)
if ($result == 57)
Use ==.
Perl
try: x = 1 / 0 except pass
try: x = 1 / 0 except Exception: pass
Specify exception type.
Python
if (x = 21)
if (x == 21)
Use ==.
R
with open('input.csv') as f: data = f.read()
with open('input.csv') as f: data = f.read()
Correct.
Python
@media screen {{ body {{}} }}
@media screen {{ body {{}} }}
Correct.
CSS
void main() {{ print('data') }}
void main() {{ print('data'); }}
Add semicolon.
Dart
let foo = 'info'
let foo = "info"
Double quotes.
Swift
[62, 9, 64
[62, 9, 64]
Close bracket.
Python
if index = 42:
if index == 42:
Use == for comparison.
Python
if (foo = 81)
if (foo == 81)
Use ==.
Scala
def render puts 'value' end
def render puts 'value' end
Correct.
Ruby
class = 'result'
class_name = 'result'
'class' is a keyword.
Python
data[82]
if (data.indices.contains(82)) data[82]
Check index.
Kotlin
$b = 5; if ($b = 5) {{}}
$b = 5; if ($b == 5) {{}}
Use ==.
PHP
SELECT * FROM users WHRE email=93;
SELECT * FROM users WHERE email=93;
Fix WHERE.
SQL
lambda x: x+1
lambda x: x+1
Correct lambda.
Python
print 'hello'
print('hello')
Parentheses for function call.
Lua
my @arr = (66,53,65);
my @arr = (66,53,65);
Correct.
Perl
if (data) console.log('yes') else console.log('no')
if (data) console.log('yes'); else console.log('no');
Missing semicolon.
JavaScript
.Order {{ color: red; }}
.Order {{ color: red; }}
Correct.
CSS
var x = 48;
var x = 48;
Correct.
Dart
for (int i=0; i<79; i++) {{}}
for (int i=0; i<79; i++) {{}}
Correct.
Java
<div><p>data</div></p>
<div><p>data</p></div>
Nest properly.
HTML
String item = 'hello';
String item = "hello";
Double quotes.
Java
while read line; do echo $line; done < input.csv
while read line; do echo $line; done < input.csv
Correct.
Shell
{ "name": "hello" }
{ "name": "hello" }
Correct.
JSON
os.sqrt(29)
import os os.sqrt(29)
Import module first.
Python
class Item def method end end
class Item def method end end
Correct.
Ruby
<br></br>
<br>
Self-closing.
HTML
function compute() {{ return {{key:'test'}} }}
function compute() {{ return {{key:'test'}}; }}
Return object on same line.
JavaScript
package main func main() {{}}
package main import 'fmt' func main() {{}}
Import needed.
Go
c = result
c = 'result'
Quote strings.
Python
class Child Entity:
class Child(Entity):
Inheritance uses parentheses.
Python
val bar: Int = 'value'
val bar: String = 'value'
Fix type.
Kotlin
if ($result = 51) {{}}
if ($result -eq 51) {{}}
Use -eq.
PowerShell
function foo(a) print(a) end
function foo(a) print(a) end
Correct.
Lua
yield b
yield b
Correct yield.
Python
<table><tr><td>test<td>test</tr></table>
<table><tr><td>test</td><td>test</td></tr></table>
Close td.
HTML
jwt.sign({{id:71}}, 'secret');
jwt.sign({{id:71}}, 'secret', {{expiresIn:'7d'}});
Add expiration.
Node.js
String name = 'data';
String name = 'data';
Correct.
Dart
<person age=12>
<person age="12">
Quote attribute.
XML
while a > 50 a -= 1
while a > 50: a -= 1
Colon missing after while.
Python
const result = 24; result = 21;
let result = 24; result = 21;
Cannot reassign const.
JavaScript
const http = require('http'); http.createServer((req,res) => res.end('world')).listen(62);
const http = require('http'); http.createServer((req,res) => res.end('world')).listen(62);
Correct.
Node.js
INSERT INTO products VALUES ('message',30)
INSERT INTO products (age, email) VALUES ('message',30);
Specify columns.
SQL
class = 'world'
class_name = 'world'
'class' is a keyword.
Python
if (item = 81)
if (item == 81)
Use ==.
Scala
lambda x: x+1
lambda x: x+1
Correct lambda.
Python
let b = 'message'
let b = "message"
Double quotes.
Swift
if ($temp = 55)
if ($temp == 55)
Use ==.
Perl
def compute(z): return z + 1
def compute(z): return z + 1
Correct.
Python
Order.save();
Order.save().then(()=>{{}}).catch(err=>{{}});
Handle promise.
Node.js
{ "name": "data" }
{ "name": "data" }
Correct.
JSON
disp('output')
disp('output')
Correct.
MATLAB
$data[13]
if ($data.Count -gt 13) {{ $data[13] }}
Check bounds.
PowerShell
x := 79
x := 79
Correct.
Go
let a: number = 'world';
let a: string = 'world';
Fix type.
TypeScript
["test", 46]
["test", 46]
Correct.
JSON
def process puts 'world' end
def process puts 'world' end
Correct.
Ruby
if c = 41 {{}}
if c == 41 {{}}
Use ==.
Swift
if (val = 74)
if (val == 74)
Use ==.
C++
$x = 5; if ($x -eq 5) { Write-Host 'yes' }
$x = 5; if ($x -eq 5) { Write-Host 'yes' }
Correct.
PowerShell
index = test
index = 'test'
Quote strings.
Python
public static void main(String[] args) {{}}
public static void main(String[] args) {{}}
Correct.
Java
List(43,45,88)
List(43,45,88)
Correct.
Scala
int[] arr = new int[53]; arr[53] = 5;
int[] arr = new int[53]; if (53 < arr.length) arr[53] = 5;
Check bounds.
Java
div {{ color=#fff; }}
div {{ color: #fff; }}
Use colon.
CSS
const int x; x = 5;
const int x = 5;
Const must be initialized.
C++
if index = 55
if index == 55
Use ==.
Ruby
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(17);
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(17, () => console.log('listening'));
Add callback.
Node.js
if (num) console.log('yes') else console.log('no')
if (num) console.log('yes'); else console.log('no');
Missing semicolon.
JavaScript
val data = 79; data = 42
var data = 79; data = 42
Use var for reassignment.
Scala
function handle(item) print(item) end
function handle(item) print(item) end
Correct.
Lua
jwt.sign({{id:34}}, 'key');
jwt.sign({{id:34}}, 'key', {{expiresIn:'7d'}});
Add expiration.
Node.js
try: x = 1 / 0 except pass
try: x = 1 / 0 except Exception: pass
Specify exception type.
Python
<div color=green>
<div style='color:green;'>
Use style attribute.
CSS
data[26]
if (length(data) >= 26) data[26]
Check length.
R
<input type='text' value='value'>
<input type='text' value='value' name='status'>
Add name attribute.
HTML
if item = 75
if item == 75
Use ==.
Go
package main func main() {{}}
package main import 'fmt' func main() {{}}
Import needed.
Go
class Item {{ int x; }};
class Item {{ public: int x; }};
Make public.
C++
var x = 5; x = "hello"
var x = "hello"
Type mismatch.
Swift
@media screen {{ body {{}} }}
@media screen {{ body {{}} }}
Correct.
CSS
String result = 'info';
String result = "info";
Double quotes.
Java
var foo int = 'result'
var foo string = 'result'
Type mismatch.
Go
type MyType = string | number; let x: MyType = true;
type MyType = string | number; let x: MyType = 'hello';
Type not in union.
TypeScript
object Order {{ def main(args: Array[String]) = println("info") }}
object Order {{ def main(args: Array[String]): Unit = println("info") }}
Add return type Unit.
Scala
let y = 29; let y = 23;
let y = 29; y = 23;
Duplicate declaration.
JavaScript
List<int> list = [1,2,3];
List<int> list = [1,2,3];
Correct.
Dart
values(93)
if length(values) >= 93, values(93), end
Check length.
MATLAB
int main() {{ return 0; }}
int main() {{ return 0; }}
Correct.
C++
[2, 60, 5
[2, 60, 5]
Close bracket.
Python