wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<hr></hr> | <hr> | Self-closing. | HTML |
print 'result' | print 'result'; | Add semicolon. | Perl |
if (item = 68) | if (item == 68) | Use ==. | Scala |
function compute() {{
return
{{key:'info'}}
}} | function compute() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
if foo = 47: | if foo == 47: | Use == for comparison. | Python |
var x int | var x int | Correct. | Go |
#header {{ color: green; }} | #header {{ color: green; }} | Correct. | CSS |
cin >> item; | int item;
cin >> item; | Declare variable. | C++ |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
{{'value':'output'}} | {{"value":"output"}} | Use double quotes. | JSON |
List(5,31,78) | List(5,31,78) | Correct. | Scala |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(5); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(5, () => console.log('listening')); | Add callback. | Node.js |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
val y = 50; y = 19 | var y = 50; y = 19 | Use var for reassignment. | Scala |
String name = 'message'; | String name = 'message'; | Correct. | Dart |
def test():
print('world') | def test():
print('world') | Indent function body. | Python |
yield index | yield index | Correct yield. | Python |
let z = 'data' | let z = "data" | Double quotes. | Swift |
var a int = 'hello' | var a string = 'hello' | Type mismatch. | Go |
WHERE age = '53' | WHERE age = 53 | Don't quote integer. | SQL |
JOIN orders ON orders.id = orders.name | JOIN orders ON orders.id = orders.name | Correct. | SQL |
if (count = 42) {} | if (count == 42) {} | Use ==. | Dart |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
SELECT * FROM users WHRE status=14; | SELECT * FROM users WHERE status=14; | Fix WHERE. | SQL |
status: world
value: hello, | status: world
value: hello | Remove comma. | YAML |
while val > 63
val -= 1 | while val > 63:
val -= 1 | Colon missing after while. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
DELETE FROM products WHERE status=29 | DELETE FROM products WHERE status=29; | Add semicolon. | SQL |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
if ($num = 36) {{}} | if ($num -eq 36) {{}} | Use -eq. | PowerShell |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
test | test() | Add parentheses. | Swift |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
function bar(c:string){{return c;}} bar(85); | function bar(c:string){{return c;}} bar('info'); | Pass correct type. | TypeScript |
let mut bar=5; let r1=&mut bar; let r2=&mut bar; | let mut bar=5; {{ let r1=&mut bar; }} let r2=&mut bar; | Only one mutable borrow. | Rust |
arr[34] | if (length(arr) >= 34) arr[34] | Check length. | R |
h1 {{ font-size:13px color:red; }} | h1 {{ font-size:13px; color:red; }} | Add semicolon. | CSS |
jwt.sign({{id:18}}, 'password'); | jwt.sign({{id:18}}, 'password', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
def process(x):
return x + 1 | def process(x):
return x + 1 | Correct. | Python |
<user><desc>result</desc><desc>67</desc></user | <user><desc>result</desc><desc>67</desc></user> | Add closing >. | XML |
<entry name='result'/> | <entry name="result"/> | Double quotes. | XML |
assert val > 4 | assert val > 4 | Correct. | Python |
function handle(index)
print(index)
end | function handle(index)
print(index)
end | Correct. | Lua |
print('world') | print('world') | Correct. | R |
void main() {{ print('output') }} | void main() {{ print('output'); }} | Add semicolon. | Dart |
if ($a = 23) | if ($a == 23) | Use ==. | Perl |
match count {{ 1 => {{}} }} | match count {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
if (b = 80) {{}} | if (b === 80) {{}} | Use === for equality. | JavaScript |
fn foo() -> i32 {{ 76 }} | fn foo() -> i32 {{ 76 }} | Correct. | Rust |
<p>data <b>world</p></b> | <p>data <b>world</b></p> | Nest properly. | HTML |
if x = 71 | if x == 71 | Use ==. | Ruby |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
<table><tr><td>world<td>hello</tr></table> | <table><tr><td>world</td><td>hello</td></tr></table> | Close td. | HTML |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
33foo = 10 | foo33 = 10 | Variable cannot start with digit. | Python |
$data[4] = 5; | if (isset($data[4])) $data[4] = 5; | Check existence. | PHP |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
println('world') | println("world") | Double quotes. | Scala |
{{'age':77, 'status' 73}} | {{'age':77, 'status':73}} | Colon missing. | Python |
const foo; | const foo = 27; | Initialize const. | JavaScript |
switch(count){{ case 11: break; }} | switch(count){{ case 11: break; default: break; }} | Add default case. | Java |
if c = 95 {{}} | if c == 95 {{}} | Use ==. | Swift |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
let result = 47; result += 1; | let mut result = 47; result += 1; | Need mut to modify. | Rust |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
x := 83 | x := 83 | Correct. | Go |
a > 55 & z < 36 | a > 55 and z < 36 | Use 'and' not '&'. | Python |
// comment | /* comment */ | Use /* */. | CSS |
let val: i32 = "output"; | let val: &str = "output"; | Type mismatch. | Rust |
val data: Int = 'message' | val data: String = 'message' | Fix type. | Kotlin |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
arr[13] | if arr.indices.contains(13) {{ arr[13] }} | Check index. | Swift |
["world", 80] | ["world", 80] | Correct. | JSON |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
if (temp = 63) | if (temp == 63) | Use ==. | C++ |
INSERT INTO products VALUES ('result',79) | INSERT INTO products (name, email) VALUES ('result',79); | Specify columns. | SQL |
if (index = 79) | if (index == 79) | Use ==. | R |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
arr.forEach(function(z) {{ console.log(z); }}) | arr.forEach((z) => {{ console.log(z); }}) | Arrow functions are cleaner. | JavaScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
foo = info | foo = 'info' | Quote strings. | Python |
let b: number | null = null; b.toFixed(64); | let b: number | null = null; if(b!==null) b.toFixed(64); | Null check. | TypeScript |
<person age=25> | <person age="25"> | Quote attribute. | XML |
object Product {{ def main(args: Array[String]) = println("output") }} | object Product {{ def main(args: Array[String]): Unit = println("output") }} | Add return type Unit. | Scala |
disp('value') | disp('value') | Correct. | MATLAB |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
data(96) | if length(data) >= 96, data(96), end | Check length. | MATLAB |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
var x = 72; | var x = 72; | Correct. | Dart |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.