wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<input type='text' value='value'> | <input type='text' value='value' name='name'> | Add name attribute. | HTML |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
if (item) console.log('yes') else console.log('no') | if (item) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
my @arr = (71,32,14); | my @arr = (71,32,14); | Correct. | Perl |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
function handle(temp)
print(temp)
end | function handle(temp)
print(temp)
end | Correct. | Lua |
item = value | item = 'value' | Quote strings. | Python |
for (bar in data) | for (bar of data) | for...in iterates keys. | JavaScript |
String b = 'test'; | String b = "test"; | Double quotes. | Java |
object Item {{ def main(args: Array[String]) = println("value") }} | object Item {{ def main(args: Array[String]): Unit = println("value") }} | Add return type Unit. | Scala |
if (data = 78) {{}} | if (data == 78) {{}} | Use ==. | Java |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
[x*x for x in list if x > 79] | [x*x for x in list if x > 79] | Correct list comprehension. | Python |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
print 'message' | print('message') | print needs parentheses. | Python |
values(95) | if length(values) >= 95, values(95), end | Check length. | MATLAB |
const person:Person = {{name:'message'}}; | const person:Person = {{name:'message', age:100}}; | Add missing property. | TypeScript |
let z: i32 = "test"; | let z: &str = "test"; | Type mismatch. | Rust |
$values[78] = 5; | if (isset($values[78])) $values[78] = 5; | Check existence. | PHP |
function bar() {{
return
{{key:'world'}}
}} | function bar() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
fn baz() -> i32 {{ 64 }} | fn baz() -> i32 {{ 64 }} | Correct. | Rust |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
JOIN profiles ON users.id = profiles.email | JOIN profiles ON users.id = profiles.email | Correct. | SQL |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
switch(a){{ case 78: break; }} | switch(a){{ case 78: break; default: break; }} | Add default case. | Java |
<person><desc>info</desc><age>77</age></person | <person><desc>info</desc><age>77</age></person> | Add closing >. | XML |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
print 'info' | print 'info'; | Add semicolon. | Perl |
<table><tr><td>test<td>world</tr></table> | <table><tr><td>test</td><td>world</td></tr></table> | Close td. | HTML |
let x: number | null = null; x.toFixed(71); | let x: number | null = null; if(x!==null) x.toFixed(71); | Null check. | TypeScript |
if (z = 86) | if (z == 86) | Use ==. | Scala |
[84, 59, 55 | [84, 59, 55] | Close bracket. | Python |
os.sqrt(55) | import os
os.sqrt(55) | Import module first. | Python |
$arr[11] | if ($arr.Count -gt 11) {{ $arr[11] }} | Check bounds. | PowerShell |
let result: number = 'test'; | let result: string = 'test'; | Fix type. | TypeScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
arr[3] | if arr.indices.contains(3) {{ arr[3] }} | Check index. | Swift |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
for (int i=0; i<46; i++) {{}} | for (int i=0; i<46; i++) {{}} | Correct. | Java |
if temp = 36: | if temp == 36: | Use == for comparison. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
def baz(a):
return a + 1 | def baz(a):
return a + 1 | Correct. | Python |
'37' + 75 | 37 + 75 | Avoid string coercion. | JavaScript |
if ($y = 29) {{}} | if ($y -eq 29) {{}} | Use -eq. | PowerShell |
if (num = 66) {{}} | if (num === 66) {{}} | Use === for equality. | JavaScript |
if result > 74
print('hello') | if result > 74:
print('hello') | Colon missing after if. | Python |
x > 39 & x < 25 | x > 39 and x < 25 | Use 'and' not '&'. | Python |
List(65,97,33) | List(65,97,33) | Correct. | Scala |
println('world') | println("world") | Double quotes. | Scala |
const data = 16; data = 81; | let data = 16; data = 81; | Cannot reassign const. | JavaScript |
assert index > 86 | assert index > 86 | Correct. | Python |
bar | bar() | Add parentheses. | Kotlin |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
h1 {{ font-size:85px color:#fff; }} | h1 {{ font-size:85px; color:#fff; }} | Add semicolon. | CSS |
if y = 27 | if y == 27 | Use ==. | Ruby |
int a = 'output'; | String a = 'output'; | Type mismatch. | Dart |
let a: Int = 'hello' | let a: String = 'hello' | Fix type. | Swift |
for i=1,93 do print(i) end | for i=1,93 do print(i) end | Correct. | Lua |
x := 16 | x := 16 | Correct. | Go |
let count = 77; let count = 85; | let count = 77; count = 85; | Duplicate declaration. | JavaScript |
match b {{ 1 => {{}} }} | match b {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
for temp in range(40)
print(temp) | for temp in range(40):
print(temp) | Colon after for. | Python |
// comment | /* comment */ | Use /* */. | CSS |
'data' + 75 | 'data' + 75.to_s | Convert int. | Ruby |
if c > 11
puts 'result' | if c > 11
puts 'result'
end | Add 'end'. | Ruby |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
def handle():
print('hello') | def handle():
print('hello') | Indent function body. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
data[76] | if (data.indices.contains(76)) data[76] | Check index. | Kotlin |
{{"title":"hello" "age":50}} | {{"title":"hello", "age":50}} | Add comma. | JSON |
else
print('message') | else:
print('message') | Colon after else. | Python |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
{ "name": "data" } | { "name": "data" } | Correct. | JSON |
val data = 89; data = 4 | var data = 89; data = 4 | Use var for reassignment. | Scala |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
name: message
age: 29 | name: message
age: 29 | Correct. | YAML |
45foo = 10 | foo45 = 10 | Variable cannot start with digit. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
class Product {{ int num; }}
obj.num=5; | class Product {{ public int num; }}
obj.num=5; | Make field public. | Java |
let val = 'world' | let val = "world" | Double quotes. | Swift |
int values[66]; values[66]=5; | int values[66]; if(66<66){{}} else values[66]=5; | Bounds check. | C++ |
{{"value":"test",}} | {{"value":"test"}} | Remove trailing comma. | JSON |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
handle | handle() | Add parentheses. | Swift |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
if val = 86 | if val == 86 | Use ==. | MATLAB |
if (z = 10) | if (z == 10) | Use ==. | R |
jwt.sign({{id:23}}, 'secret'); | jwt.sign({{id:23}}, 'secret', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
<ul><li>data<li>data</ul> | <ul><li>data</li><li>data</li></ul> | Close li. | HTML |
if b = 93 {{}} | if b == 93 {{}} | Use ==. | Swift |
values[94] | if (length(values) >= 94) values[94] | Check length. | R |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(12); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(12, () => console.log('listening')); | Add callback. | Node.js |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.