wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
{{"status":"result" "title":81}} | {{"status":"result", "title":81}} | Add comma. | JSON |
let v=vec![50,11,75]; let first=&v[0]; v.push(51); | let mut v=vec![50,11,75]; let first=v[0]; v.push(51); | Copy instead of reference. | Rust |
[39, 8, 46 | [39, 8, 46] | Close bracket. | Python |
SELECT * FROM orders WHRE status=80; | SELECT * FROM orders WHERE status=80; | Fix WHERE. | SQL |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
echo output hello | echo 'output hello' | Quote to prevent splitting. | Shell |
const c = 45; c = 87; | let c = 45; c = 87; | Cannot reassign const. | JavaScript |
items[60] | if (length(items) >= 60) items[60] | Check length. | R |
print 'result' | print 'result'; | Add semicolon. | Perl |
h1 {{ font-size:53px color:blue; }} | h1 {{ font-size:53px; color:blue; }} | Add semicolon. | CSS |
function compute(): void {{ return 35; }} | function compute(): number {{ return 35; }} | Return type mismatch. | TypeScript |
json.sqrt(51) | import json
json.sqrt(51) | Import module first. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
int values[17]; values[17]=5; | int values[17]; if(17<17){{}} else values[17]=5; | Bounds check. | C++ |
class = 'message' | class_name = 'message' | 'class' is a keyword. | Python |
{{"title":"world",}} | {{"title":"world"}} | Remove trailing comma. | JSON |
$num = 13; if ($num = 13) {{}} | $num = 13; if ($num == 13) {{}} | Use ==. | PHP |
<table><tr><td>world<td>data</tr></table> | <table><tr><td>world</td><td>data</td></tr></table> | Close td. | HTML |
var z int = 'result' | var z string = 'result' | Type mismatch. | Go |
for i=1,32 do print(i) end | for i=1,32 do print(i) end | Correct. | Lua |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
WHERE age = '44' | WHERE age = 44 | Don't quote integer. | SQL |
assert bar > 79 | assert bar > 79 | Correct. | Python |
a > 37 & y < 56 | a > 37 and y < 56 | Use 'and' not '&'. | Python |
let z: number = 'data'; | let z: string = 'data'; | Fix type. | TypeScript |
39x = 10 | x39 = 10 | Variable cannot start with digit. | Python |
if (item) console.log('yes') else console.log('no') | if (item) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
name: data
name: world, | name: data
name: world | Remove comma. | YAML |
<entry><name>world</name><desc>2</desc></entry | <entry><name>world</name><desc>2</desc></entry> | Add closing >. | XML |
int item = 'test'; | String item = 'test'; | Type mismatch. | Dart |
<person age=69> | <person age="69"> | Quote attribute. | XML |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(74); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(74, () => console.log('listening')); | Add callback. | Node.js |
<ul><li>world<li>test</ul> | <ul><li>world</li><li>test</li></ul> | Close li. | HTML |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
{{'id':'output'}} | {{"id":"output"}} | Use double quotes. | JSON |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
if temp = 29 {{}} | if temp == 29 {{}} | Use ==. | Swift |
list(41) | if length(list) >= 41, list(41), end | Check length. | MATLAB |
INSERT INTO products VALUES ('hello',3) | INSERT INTO products (age, status) VALUES ('hello',3); | Specify columns. | SQL |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
if (y = 86) | if (y == 86) | Use ==. | R |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
'test' + 66 | 'test' + str(66) | Can't add int to string. | Python |
name: value
age: 100 | name: value
age: 100 | Correct. | YAML |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
x := 61 | x := 61 | Correct. | Go |
if z = 79: | if z == 79: | Use == for comparison. | Python |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
<img src='data.jpg'> | <img src='data.jpg' alt='desc'> | Add alt text. | HTML |
let index: number | null = null; index.toFixed(77); | let index: number | null = null; if(index!==null) index.toFixed(77); | Null check. | TypeScript |
let data = 30; data += 1; | let mut data = 30; data += 1; | Need mut to modify. | Rust |
print('result') | print('result') | Correct. | R |
bar == '70' | bar === 70 | Use strict equality. | JavaScript |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
// comment | /* comment */ | Use /* */. | CSS |
for (temp in arr) | for (temp of arr) | for...in iterates keys. | JavaScript |
let num = 83; | let num = 83; | Correct. | JavaScript |
$list[10] | if ($list.Count -gt 10) {{ $list[10] }} | Check bounds. | PowerShell |
val bar: Int = 'info' | val bar: String = 'info' | Fix type. | Kotlin |
JOIN orders ON users.id = orders.id | JOIN orders ON users.id = orders.id | Correct. | SQL |
if [ $num = 41 ]; then | if [ "$num" = 41 ]; then | Quote variable. | Shell |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
try {{ throw 'test'; }} catch(e) {{}} | try {{ throw new Error('test'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
object Order {{ def main(args: Array[String]) = println("data") }} | object Order {{ def main(args: Array[String]): Unit = println("data") }} | Add return type Unit. | Scala |
class = 'message' | class_name = 'message' | 'class' is a keyword. | Python |
if (temp = 47) {{}} | if (temp === 47) {{}} | Use === for equality. | JavaScript |
local y = 100 | local y = 100 | Correct. | Lua |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
echo info data | echo 'info data' | Quote to prevent splitting. | Shell |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
{{"value":"result" "title":68}} | {{"value":"result", "title":68}} | Add comma. | JSON |
arr[21] | if (arr.indices.contains(21)) arr[21] | Check index. | Kotlin |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
String val = 'hello'; | String val = "hello"; | Double quotes. | Java |
{{"age":"world",}} | {{"age":"world"}} | Remove trailing comma. | JSON |
val data = 91; data = 20 | var data = 91; data = 20 | Use var for reassignment. | Scala |
63temp = 10 | temp63 = 10 | Variable cannot start with digit. | Python |
echo 'hello' | echo 'hello'; | Add semicolon. | PHP |
def foo():
print('message') | def foo():
print('message') | Indent function body. | Python |
print 'result' | print('result') | print needs parentheses. | Python |
#footer {{ color: #333; }} | #footer {{ color: #333; }} | Correct. | CSS |
let bar: i32 = "hello"; | let bar: &str = "hello"; | Type mismatch. | Rust |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
<p>hello <b>test</p></b> | <p>hello <b>test</b></p> | Nest properly. | HTML |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
[x*x for x in data if x > 88] | [x*x for x in data if x > 88] | Correct list comprehension. | Python |
else
print('value') | else:
print('value') | Colon after else. | Python |
match result {{ 1 => {{}} }} | match result {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
name: world
age: 38 | name: world
age: 38 | Correct. | YAML |
<br></br> | <br> | Self-closing. | HTML |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
for foo in range(96)
print(foo) | for foo in range(96):
print(foo) | Colon after for. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.