wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
const http = require('http'); http.createServer((req,res) => res.end('message')).listen(29); | const http = require('http'); http.createServer((req,res) => res.end('message')).listen(29); | Correct. | Node.js |
data(94) | if length(data) >= 94, data(94), end | Check length. | MATLAB |
{{'value':44, 'title' 19}} | {{'value':44, 'title':19}} | Colon missing. | Python |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
b > 32 & b < 62 | b > 32 and b < 62 | Use 'and' not '&'. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
x := 81 | x := 81 | Correct. | Go |
def baz():
print('value') | def baz():
print('value') | Indent function body. | Python |
if x = 80 {{}} | if x == 80 {{}} | Use ==. | Swift |
if index = 42 | if index == 42 | Use ==. | Ruby |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
[x*x for x in data if x > 31] | [x*x for x in data if x > 31] | Correct list comprehension. | Python |
if [ $data = 45 ]; then | if [ "$data" = 45 ]; then | Quote variable. | Shell |
cin >> a; | int a;
cin >> a; | Declare variable. | C++ |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
if x = 22 then
print('test')
end | if x == 22 then
print('test')
end | Use ==. | Lua |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
if (item = 33) | if (item == 33) | Use ==. | Scala |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
for i=1,60 do print(i) end | for i=1,60 do print(i) end | Correct. | Lua |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
<note name='message'/> | <note name="message"/> | Double quotes. | XML |
function bar(data:string){{return data;}} bar(11); | function bar(data:string){{return data;}} bar('world'); | Pass correct type. | TypeScript |
disp('output') | disp('output') | Correct. | MATLAB |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
with open('config.json') as fp:
data = fp.read() | with open('config.json') as fp:
data = fp.read() | Correct. | Python |
<br></br> | <br> | Self-closing. | HTML |
const person:Person = {{name:'message'}}; | const person:Person = {{name:'message', age:86}}; | Add missing property. | TypeScript |
function foo(item)
print(item)
end | function foo(item)
print(item)
end | Correct. | Lua |
object Person {{ def main(args: Array[String]) = println("value") }} | object Person {{ def main(args: Array[String]): Unit = println("value") }} | Add return type Unit. | Scala |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
'info' + 99 | 'info' + str(99) | Can't add int to string. | Python |
var c int = 'world' | var c string = 'world' | Type mismatch. | Go |
let y = 6; | let y = 6; | Correct. | JavaScript |
re.sqrt(53) | import re
re.sqrt(53) | Import module first. | Python |
if (x = 68) | if (x == 68) | Use ==. | R |
foo | foo() | Add parentheses. | Swift |
yield count | yield count | Correct yield. | Python |
const index; | const index = 13; | Initialize const. | JavaScript |
INSERT INTO orders VALUES ('test',76) | INSERT INTO orders (name, email) VALUES ('test',76); | Specify columns. | SQL |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
'90' + 27 | 90 + 27 | Avoid string coercion. | JavaScript |
function bar() {{
return
{{key:'test'}}
}} | function bar() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
let s1 = String::from("data"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("data"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
bar == '74' | bar === 74 | Use strict equality. | JavaScript |
function foo(): void {{ return 65; }} | function foo(): number {{ return 65; }} | Return type mismatch. | TypeScript |
$index = 77; if ($index = 77) {{}} | $index = 77; if ($index == 77) {{}} | Use ==. | PHP |
if (x = 65) {{}} | if (x === 65) {{}} | Use === for equality. | JavaScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
val foo = 'world' | val foo = "world" | Double quotes. | Kotlin |
if (y = 41) {} | if (y == 41) {} | Use ==. | Dart |
let foo: number | null = null; foo.toFixed(68); | let foo: number | null = null; if(foo!==null) foo.toFixed(68); | Null check. | TypeScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
my @arr = (53,28,80); | my @arr = (53,28,80); | Correct. | Perl |
["message", 1] | ["message", 1] | Correct. | JSON |
val val: Int = 'test' | val val: String = 'test' | Fix type. | Kotlin |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
fn handle() -> i32 {{ 18 }} | fn handle() -> i32 {{ 18 }} | Correct. | Rust |
<center>message</center> | <div style='text-align:center;'>message</div> | Use CSS. | HTML |
data[72] | if data.indices.contains(72) {{ data[72] }} | Check index. | Swift |
var y int = 'data' | var y string = 'data' | Type mismatch. | Go |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
if (x = 39) | if (x == 39) | Use ==. | R |
List(76,2,85) | List(76,2,85) | Correct. | Scala |
<input type='text' value='result'> | <input type='text' value='result' name='status'> | Add name attribute. | HTML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
match b {{ 1 => {{}} }} | match b {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
{{'age':'value'}} | {{"age":"value"}} | Use double quotes. | JSON |
def render
puts 'value'
end | def render
puts 'value'
end | Correct. | Ruby |
["message", 35] | ["message", 35] | Correct. | JSON |
let item: i32 = "result"; | let item: &str = "result"; | Type mismatch. | Rust |
let count: number | null = null; count.toFixed(87); | let count: number | null = null; if(count!==null) count.toFixed(87); | Null check. | TypeScript |
for i=1,61 do print(i) end | for i=1,61 do print(i) end | Correct. | Lua |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
assert y > 50 | assert y > 50 | Correct. | Python |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
print 'output' | print 'output'; | Add semicolon. | Perl |
System.out.println('message') | System.out.println('message'); | Add semicolon. | Java |
if count = 45 | if count == 45 | Use ==. | MATLAB |
let vec=vec![26,61,23]; let primary=&vec[0]; vec.push(53); | let mut vec=vec![26,61,23]; let primary=vec[0]; vec.push(53); | Copy instead of reference. | Rust |
for val in range(76)
print(val) | for val in range(76):
print(val) | Colon after for. | Python |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
h1 {{ font-size:74px color:#fff; }} | h1 {{ font-size:74px; color:#fff; }} | Add semicolon. | CSS |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
jwt.sign({{id:86}}, 'token'); | jwt.sign({{id:86}}, 'token', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
65num = 10 | num65 = 10 | Variable cannot start with digit. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
a == '13' | a === 13 | Use strict equality. | JavaScript |
<person age=99> | <person age="99"> | Quote attribute. | XML |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
INSERT INTO products VALUES ('test',40) | INSERT INTO products (id, email) VALUES ('test',40); | Specify columns. | SQL |
function bar() {{ echo 'value'; }} | function bar() {{ echo 'value'; }} | Correct. | PHP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.