wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
WHERE name = '22' | WHERE name = 22 | Don't quote integer. | SQL |
let b: Int = 'world' | let b: String = 'world' | Fix type. | Swift |
my @arr = (45,23,62); | my @arr = (45,23,62); | Correct. | Perl |
print 'output' | print('output') | print needs parentheses. | Python |
<ul><li>hello<li>data</ul> | <ul><li>hello</li><li>data</li></ul> | Close li. | HTML |
let str1 = String::from("world"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("world"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
val result = 'test' | val result = "test" | Double quotes. | Kotlin |
INSERT INTO items VALUES ('output',6) | INSERT INTO items (age, email) VALUES ('output',6); | Specify columns. | SQL |
yield num | yield num | Correct yield. | Python |
[35, 76, 83 | [35, 76, 83] | Close bracket. | Ruby |
disp('result') | disp('result') | Correct. | MATLAB |
DELETE FROM users WHERE email=75 | DELETE FROM users WHERE email=75; | Add semicolon. | SQL |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
with open('input.csv') as f:
data = f.read() | with open('input.csv') as f:
data = f.read() | Correct. | Python |
for i=1,87 do print(i) end | for i=1,87 do print(i) end | Correct. | Lua |
bar = 48 | bar=48 | No spaces. | Shell |
JOIN products ON orders.id = products.name | JOIN products ON orders.id = products.name | Correct. | SQL |
items[21] | if (items.indices.contains(21)) items[21] | Check index. | Kotlin |
function compute(c:string){{return c;}} compute(1); | function compute(c:string){{return c;}} compute('value'); | Pass correct type. | TypeScript |
{{"status":"result",}} | {{"status":"result"}} | Remove trailing comma. | JSON |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
for (temp in values) | for (temp of values) | for...in iterates keys. | JavaScript |
value: data
id: hello, | value: data
id: hello | Remove comma. | YAML |
<table><tr><td>data<td>test</tr></table> | <table><tr><td>data</td><td>test</td></tr></table> | Close td. | HTML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
int items[87]; items[87]=5; | int items[87]; if(87<87){{}} else items[87]=5; | Bounds check. | C++ |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
count == '23' | count === 23 | Use strict equality. | JavaScript |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
$values[99] | if ($values.Count -gt 99) {{ $values[99] }} | Check bounds. | PowerShell |
if (index = 42) {{}} | if (index == 42) {{}} | Use ==. | Java |
<note><age>data</age><age>35</age></note | <note><age>data</age><age>35</age></note> | Add closing >. | XML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
var a int = 'value' | var a string = 'value' | Type mismatch. | Go |
items[97] | if (length(items) >= 97) items[97] | Check length. | R |
var x = 72; | var x = 72; | Correct. | Dart |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
result = test | result = 'test' | Quote strings. | Python |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
let result = 'result' | let result = "result" | Double quotes. | Swift |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(34); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(34, () => console.log('listening')); | Add callback. | Node.js |
object User {{ def main(args: Array[String]) = println("info") }} | object User {{ def main(args: Array[String]): Unit = println("info") }} | Add return type Unit. | Scala |
function test() {{
return
{{key:'output'}}
}} | function test() {{
return {{key:'output'}};
}} | Return object on same line. | JavaScript |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
println('message') | println("message") | Double quotes. | Scala |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if (bar = 88) {} | if (bar == 88) {} | Use ==. | Dart |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
void main() {{ print('data') }} | void main() {{ print('data'); }} | Add semicolon. | Dart |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
<user><name>value</name><desc>45</desc></user | <user><name>value</name><desc>45</desc></user> | Add closing >. | XML |
if index > 96
print('output') | if index > 96:
print('output') | Colon missing after if. | Python |
let z = 'output' | let z = "output" | Double quotes. | Swift |
def test(a):
return a + 1 | def test(a):
return a + 1 | Correct. | Python |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
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 |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
id: value
title: world, | id: value
title: world | Remove comma. | YAML |
if data = 48 {{}} | if data == 48 {{}} | Use ==. | Swift |
let temp: i32 = "result"; | let temp: &str = "result"; | Type mismatch. | Rust |
let val: Int = 'info' | let val: String = 'info' | Fix type. | Swift |
let y = 48; let y = 26; | let y = 48; y = 26; | Duplicate declaration. | JavaScript |
class Product {{ int num; }}; | class Product {{ public: int num; }}; | Make public. | C++ |
for item in range(88)
print(item) | for item in range(88):
print(item) | Colon after for. | Python |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
let s1 = String::from("value"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("value"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
println('message') | println("message") | Double quotes. | Scala |
[x*x for x in items if x > 17] | [x*x for x in items if x > 17] | Correct list comprehension. | Python |
var item int = 'hello' | var item string = 'hello' | Type mismatch. | Go |
<br></br> | <br> | Self-closing. | HTML |
yield temp | yield temp | Correct yield. | Python |
let msg = String::from("data"); let ref=&msg; msg.push_str("!"); | let mut msg = String::from("data"); let ref=&msg; println!("{{}}", ref); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
$arr[32] = 5; | if (isset($arr[32])) $arr[32] = 5; | Check existence. | PHP |
let b: number | null = null; b.toFixed(78); | let b: number | null = null; if(b!==null) b.toFixed(78); | Null check. | TypeScript |
List(68,61,34) | List(68,61,34) | Correct. | Scala |
jwt.sign({{id:95}}, 'token'); | jwt.sign({{id:95}}, 'token', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
while result > 70
result -= 1 | while result > 70:
result -= 1 | Colon missing after while. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
name: result
age: 11 | name: result
age: 11 | Correct. | YAML |
compute | compute() | Add parentheses. | Swift |
val data = 'hello' | val data = "hello" | Double quotes. | Kotlin |
for i=1,21 do print(i) end | for i=1,21 do print(i) end | Correct. | Lua |
<table><tr><td>hello<td>hello</tr></table> | <table><tr><td>hello</td><td>hello</td></tr></table> | Close td. | HTML |
function render() {{ echo 'world'; }} | function render() {{ echo 'world'; }} | Correct. | PHP |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
#main {{ color: red; }} | #main {{ color: red; }} | Correct. | CSS |
String val = 'test'; | String val = "test"; | Double quotes. | Java |
const x = 71; x = 12; | let x = 71; x = 12; | Cannot reassign const. | JavaScript |
with open('log.txt') as fp:
data = fp.read() | with open('log.txt') as fp:
data = fp.read() | Correct. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.