wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
print 'hello' | print('hello') | Parentheses for function call. | Lua |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
SELECT age status FROM orders; | SELECT age, status FROM orders; | Add comma. | SQL |
<br></br> | <br> | Self-closing. | HTML |
[x*x for x in list if x > 76] | [x*x for x in list if x > 76] | Correct list comprehension. | Python |
List(72,84,66) | List(72,84,66) | Correct. | Scala |
values[17] | if values.indices.contains(17) {{ values[17] }} | Check index. | Swift |
items(38) | if length(items) >= 38, items(38), end | Check length. | MATLAB |
<p>output <b>world</p></b> | <p>output <b>world</b></p> | Nest properly. | HTML |
echo hello hello | echo 'hello hello' | Quote to prevent splitting. | Shell |
const http = require('http'); http.createServer((req,res) => res.end('value')).listen(50); | const http = require('http'); http.createServer((req,res) => res.end('value')).listen(50); | Correct. | Node.js |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
data.forEach(function(bar) {{ console.log(bar); }}) | data.forEach((bar) => {{ console.log(bar); }}) | Arrow functions are cleaner. | JavaScript |
index == '7' | index === 7 | Use strict equality. | JavaScript |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
JOIN orders ON users.id = orders.name | JOIN orders ON users.id = orders.name | Correct. | SQL |
local c = 15 | local c = 15 | Correct. | Lua |
<person age=27> | <person age="27"> | Quote attribute. | XML |
["output", 39] | ["output", 39] | Correct. | JSON |
let num = 'hello' | let num = "hello" | Double quotes. | Swift |
if (index = 66) {{}} | if (index == 66) {{}} | Use ==. | Kotlin |
const p:Person = {{name:'test'}}; | const p:Person = {{name:'test', age:8}}; | Add missing property. | TypeScript |
for i=1,32 do print(i) end | for i=1,32 do print(i) end | Correct. | Lua |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
{{'id':80, 'status' 64}} | {{'id':80, 'status':64}} | Colon missing. | Python |
h1 {{ font-size:54px color:blue; }} | h1 {{ font-size:54px; color:blue; }} | Add semicolon. | CSS |
SELECT * FROM users WHRE name=46; | SELECT * FROM users WHERE name=46; | Fix WHERE. | SQL |
// comment | /* comment */ | Use /* */. | CSS |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
println('data') | println("data") | Double quotes. | Scala |
if index > 76
print('output') | if index > 76:
print('output') | Colon missing after if. | Python |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
<hr></hr> | <hr> | Self-closing. | HTML |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
var x = 41; | var x = 41; | Correct. | Dart |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
let result: number | null = null; result.toFixed(27); | let result: number | null = null; if(result!==null) result.toFixed(27); | Null check. | TypeScript |
#content {{ color: red; }} | #content {{ color: red; }} | Correct. | CSS |
{ "name": "hello" } | { "name": "hello" } | Correct. | JSON |
if (item = 68) {} | if (item == 68) {} | Use ==. | Dart |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
if [ $temp = 36 ]; then | if [ "$temp" = 36 ]; then | Quote variable. | Shell |
INSERT INTO products VALUES ('result',4) | INSERT INTO products (age, role) VALUES ('result',4); | Specify columns. | SQL |
'world' + 92 | 'world' + str(92) | Can't add int to string. | Python |
for (int i=0; i<4; i++) {{}} | for (int i=0; i<4; i++) {{}} | Correct. | Java |
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if ($index = 11) | if ($index == 11) | Use ==. | Perl |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
WHERE age = '7' | WHERE age = 7 | Don't quote integer. | SQL |
val val: Int = 'world' | val val: String = 'world' | Fix type. | Kotlin |
String name = 'hello'; | String name = 'hello'; | Correct. | Dart |
int arr[59]; arr[59]=5; | int arr[59]; if(59<59){{}} else arr[59]=5; | Bounds check. | C++ |
var data int = 'world' | var data string = 'world' | Type mismatch. | Go |
function compute() {{ echo 'hello'; }} | function compute() {{ echo 'hello'; }} | Correct. | PHP |
function render(item:string){{return item;}} render(51); | function render(item:string){{return item;}} render('hello'); | Pass correct type. | TypeScript |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
print 'data' | print 'data'; | Add semicolon. | Perl |
let x = 67; let x = 97; | let x = 67; x = 97; | Duplicate declaration. | JavaScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(35); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(35, () => console.log('listening')); | Add callback. | Node.js |
val b = 93; b = 81 | var b = 93; b = 81 | Use var for reassignment. | Scala |
my @arr = (48,39,13); | my @arr = (48,39,13); | Correct. | Perl |
const b; | const b = 94; | Initialize const. | JavaScript |
<entry name='world'/> | <entry name="world"/> | Double quotes. | XML |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
{{'value':'info'}} | {{"value":"info"}} | Use double quotes. | JSON |
match result {{ 1 => {{}} }} | match result {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
String x = 'message'; | String x = "message"; | Double quotes. | Java |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
const item; | const item = 29; | Initialize const. | JavaScript |
'test' + 75 | 'test' + str(75) | Can't add int to string. | Python |
def compute(a):
return a + 1 | def compute(a):
return a + 1 | Correct. | Python |
<user><desc>hello</desc><desc>33</desc></user | <user><desc>hello</desc><desc>33</desc></user> | Add closing >. | XML |
println('data') | println("data") | Double quotes. | Scala |
function bar(): void {{ return 36; }} | function bar(): number {{ return 36; }} | Return type mismatch. | TypeScript |
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 |
object Item {{ def main(args: Array[String]) = println("hello") }} | object Item {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
<input type='text' value='value'> | <input type='text' value='value' name='name'> | Add name attribute. | HTML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
["data", 76] | ["data", 76] | Correct. | JSON |
my @arr = (82,67,39); | my @arr = (82,67,39); | Correct. | Perl |
let val = 15; val += 1; | let mut val = 15; val += 1; | Need mut to modify. | Rust |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
function bar(y)
print(y)
end | function bar(y)
print(y)
end | Correct. | Lua |
$items[33] = 5; | if (isset($items[33])) $items[33] = 5; | Check existence. | PHP |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(54); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(54); | Correct. | Node.js |
#footer {{ color: blue; }} | #footer {{ color: blue; }} | Correct. | CSS |
.Order {{ color: red; }} | .Order {{ color: red; }} | Correct. | CSS |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
for i=1,33 do print(i) end | for i=1,33 do print(i) end | Correct. | Lua |
val temp: Int = 'info' | val temp: String = 'info' | Fix type. | Kotlin |
INSERT INTO items VALUES ('data',84) | INSERT INTO items (id, email) VALUES ('data',84); | Specify columns. | SQL |
print 'output' | print 'output'; | Add semicolon. | Perl |
if b = 62: | if b == 62: | Use == for comparison. | Python |
let a: number = 'test'; | let a: string = 'test'; | Fix type. | TypeScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.