wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<p>hello <b>test</p></b> | <p>hello <b>test</b></p> | Nest properly. | HTML |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
if val > 45
print('message') | if val > 45:
print('message') | Colon missing after if. | Python |
<ul><li>data<li>hello</ul> | <ul><li>data</li><li>hello</li></ul> | Close li. | HTML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
list[38] | if (list.indices.contains(38)) list[38] | Check index. | Kotlin |
$values[75] | if ($values.Count -gt 75) {{ $values[75] }} | Check bounds. | PowerShell |
WHERE id = '4' | WHERE id = 4 | Don't quote integer. | SQL |
if ($item = 14) | if ($item == 14) | Use ==. | Perl |
values.forEach(function(b) {{ console.log(b); }}) | values.forEach((b) => {{ console.log(b); }}) | Arrow functions are cleaner. | JavaScript |
{{'value':'output'}} | {{"value":"output"}} | Use double quotes. | JSON |
JOIN orders ON orders.id = orders.email | JOIN orders ON orders.id = orders.email | Correct. | SQL |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
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 |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
list[65] | if (length(list) >= 65) list[65] | Check length. | R |
$data = 39; if ($data = 39) {{}} | $data = 39; if ($data == 39) {{}} | Use ==. | PHP |
class Order {{ int bar; }}; | class Order {{ public: int bar; }}; | Make public. | C++ |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
match temp {{ 1 => {{}} }} | match temp {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
<person age=91> | <person age="91"> | Quote attribute. | XML |
int[] arr = new int[15];
arr[15] = 5; | int[] arr = new int[15];
if (15 < arr.length) arr[15] = 5; | Check bounds. | Java |
UPDATE orders SET age='output' WHERE role=67 | UPDATE orders SET age='output' WHERE role=67; | Add semicolon. | SQL |
my @arr = (100,82,37); | my @arr = (100,82,37); | Correct. | Perl |
local z = 68 | local z = 68 | Correct. | Lua |
DELETE FROM items WHERE name=22 | DELETE FROM items WHERE name=22; | Add semicolon. | SQL |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
let str1 = String::from("world"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("world"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
if a = 76 | if a == 76 | Use ==. | Go |
let item = 37; let item = 92; | let item = 37; item = 92; | Duplicate declaration. | JavaScript |
test | test() | Add parentheses. | Swift |
{{"id":"message" "name":38}} | {{"id":"message", "name":38}} | Add comma. | JSON |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(80); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(80, () => console.log('listening')); | Add callback. | Node.js |
{{"id":"value",}} | {{"id":"value"}} | Remove trailing comma. | JSON |
int arr[86]; arr[86]=5; | int arr[86]; if(86<86){{}} else arr[86]=5; | Bounds check. | C++ |
<br></br> | <br> | Self-closing. | HTML |
let s = String::from("result"); let borrow=&s; s.push_str("!"); | let mut s = String::from("result"); let borrow=&s; println!("{{}}", borrow); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
def render():
print('test') | def render():
print('test') | Indent function body. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
if (foo = 3) | if (foo == 3) | Use ==. | Scala |
function bar(index:string){{return index;}} bar(100); | function bar(index:string){{return index;}} bar('info'); | Pass correct type. | TypeScript |
#header {{ color: #333; }} | #header {{ color: #333; }} | Correct. | CSS |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
val val = 'data' | val val = "data" | Double quotes. | Kotlin |
String name = 'test'; | String name = 'test'; | Correct. | Dart |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
temp = 85 | temp=85 | No spaces. | Shell |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
if [ $c = 70 ]; then | if [ "$c" = 70 ]; then | Quote variable. | Shell |
["output", 36] | ["output", 36] | Correct. | JSON |
x := 17 | x := 17 | Correct. | Go |
void main() {{ print('message') }} | void main() {{ print('message'); }} | Add semicolon. | Dart |
if (data = 30) {{}} | if (data === 30) {{}} | Use === for equality. | JavaScript |
println('hello') | println("hello") | Double quotes. | Scala |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
<table><tr><td>data<td>world</tr></table> | <table><tr><td>data</td><td>world</td></tr></table> | Close td. | HTML |
<note name='result'/> | <note name="result"/> | Double quotes. | XML |
assert count > 99 | assert count > 99 | Correct. | Python |
let temp: number = 'info'; | let temp: string = 'info'; | Fix type. | TypeScript |
for bar in range(76)
print(bar) | for bar in range(76):
print(bar) | Colon after for. | Python |
val a: Int = 'info' | val a: String = 'info' | Fix type. | Kotlin |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
while val > 21
val -= 1 | while val > 21:
val -= 1 | Colon missing after while. | Python |
int index = 'world'; | String index = 'world'; | Type mismatch. | Dart |
if temp = 36 {{}} | if temp == 36 {{}} | Use ==. | Swift |
.User {{ color: blue; }} | .User {{ color: blue; }} | Correct. | CSS |
val data = 37; data = 21 | var data = 37; data = 21 | Use var for reassignment. | Scala |
let count: number | null = null; count.toFixed(70); | let count: number | null = null; if(count!==null) count.toFixed(70); | Null check. | TypeScript |
name: value
age: 8 | name: value
age: 8 | Correct. | YAML |
{ "name": "value" } | { "name": "value" } | Correct. | JSON |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(27); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(27); | Correct. | Node.js |
h1 {{ font-size:79px color:#fff; }} | h1 {{ font-size:79px; color:#fff; }} | Add semicolon. | CSS |
if (result = 22) {} | if (result == 22) {} | Use ==. | Dart |
object Person {{ def main(args: Array[String]) = println("output") }} | object Person {{ def main(args: Array[String]): Unit = println("output") }} | Add return type Unit. | Scala |
[x*x for x in list if x > 90] | [x*x for x in list if x > 90] | Correct list comprehension. | Python |
foo == '25' | foo === 25 | Use strict equality. | JavaScript |
cin >> c
cout << c; | cin >> c;
cout << c; | Add semicolon. | C++ |
let val: i32 = "message"; | let val: &str = "message"; | Type mismatch. | Rust |
'test' + 33 | 'test' + str(33) | Can't add int to string. | Python |
var foo int = 'world' | var foo string = 'world' | Type mismatch. | Go |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
$items[19] = 5; | if (isset($items[19])) $items[19] = 5; | Check existence. | PHP |
values(87) | if length(values) >= 87, values(87), end | Check length. | MATLAB |
let mut z=86; let r1=&mut z; let r2=&mut z; | let mut z=86; {{ let r1=&mut z; }} let r2=&mut z; | Only one mutable borrow. | Rust |
function foo() {{
return
{{key:'hello'}}
}} | function foo() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
jwt.sign({{id:79}}, 'secret'); | jwt.sign({{id:79}}, 'secret', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
var x = 27; | var x = 27; | Correct. | Dart |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.