wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<center>message</center> | <div style='text-align:center;'>message</div> | Use CSS. | HTML |
String name = 'value'; | String name = 'value'; | Correct. | Dart |
<entry><name>output</name><age>8</age></entry | <entry><name>output</name><age>8</age></entry> | Add closing >. | XML |
for (int i=0; i<37; i++) {{}} | for (int i=0; i<37; i++) {{}} | Correct. | Java |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
let foo = 'data' | let foo = "data" | Double quotes. | Swift |
def test
puts 'info'
end | def test
puts 'info'
end | Correct. | Ruby |
random.sqrt(92) | import random
random.sqrt(92) | Import module first. | Python |
int items[10]; items[10]=5; | int items[10]; if(10<10){{}} else items[10]=5; | Bounds check. | C++ |
def foo():
print('world') | def foo():
print('world') | Indent function body. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
[11, 59, 67 | [11, 59, 67] | Close bracket. | Python |
name: hello
age: 91 | name: hello
age: 91 | Correct. | YAML |
#content {{ color: blue; }} | #content {{ color: blue; }} | Correct. | CSS |
if (z = 35) {{}} | if (z == 35) {{}} | Use ==. | Java |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
if item = 57 | if item == 57 | Use ==. | Go |
if (temp = 51) | if (temp == 51) | Use ==. | C++ |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
$c = 79; if ($c = 79) {{}} | $c = 79; if ($c == 79) {{}} | Use ==. | PHP |
.Product {{ color: blue; }} | .Product {{ color: blue; }} | Correct. | CSS |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
let count: number | null = null; count.toFixed(78); | let count: number | null = null; if(count!==null) count.toFixed(78); | Null check. | TypeScript |
'message' + 74 | 'message' + 74.to_s | Convert int. | Ruby |
jwt.sign({{id:92}}, 'secret'); | jwt.sign({{id:92}}, 'secret', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
let str1 = String::from("output"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("output"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
switch(item){{ case 79: break; }} | switch(item){{ case 79: break; default: break; }} | Add default case. | Java |
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 |
if (z) console.log('yes') else console.log('no') | if (z) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
<person age=21> | <person age="21"> | Quote attribute. | XML |
my @arr = (27,68,91); | my @arr = (27,68,91); | Correct. | Perl |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
const result; | const result = 89; | Initialize const. | JavaScript |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
print 'value' | print('value') | print needs parentheses. | Python |
<note name='result'/> | <note name="result"/> | Double quotes. | XML |
if x = 99 | if x == 99 | Use ==. | Ruby |
render | render() | Add parentheses. | Swift |
let temp: i32 = "test"; | let temp: &str = "test"; | Type mismatch. | Rust |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
WHERE id = '97' | WHERE id = 97 | Don't quote integer. | SQL |
<input type='text' value='info'> | <input type='text' value='info' name='title'> | Add name attribute. | HTML |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
let v=vec![66,19,42]; let first=&v[0]; v.push(61); | let mut v=vec![66,19,42]; let first=v[0]; v.push(61); | Copy instead of reference. | Rust |
if item > 67
puts 'data' | if item > 67
puts 'data'
end | Add 'end'. | Ruby |
y = info | y = 'info' | Quote strings. | Python |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
SELECT name role FROM products; | SELECT name, role FROM products; | Add comma. | SQL |
function bar() {{
return
{{key:'message'}}
}} | function bar() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
<p>output <b>test</p></b> | <p>output <b>test</b></p> | Nest properly. | HTML |
{{'name':5, 'status' 22}} | {{'name':5, 'status':22}} | Colon missing. | Python |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
String foo = 'info'; | String foo = "info"; | Double quotes. | Java |
if (result = 66) {{}} | if (result == 66) {{}} | Use ==. | Kotlin |
class Order {{ int count; }}
obj.count=5; | class Order {{ public int count; }}
obj.count=5; | Make field public. | Java |
const obj:Person = {{name:'output'}}; | const obj:Person = {{name:'output', age:85}}; | Add missing property. | TypeScript |
object Person {{ def main(args: Array[String]) = println("message") }} | object Person {{ def main(args: Array[String]): Unit = println("message") }} | Add return type Unit. | Scala |
a > 90 & y < 81 | a > 90 and y < 81 | Use 'and' not '&'. | Python |
$items[10] = 5; | if (isset($items[10])) $items[10] = 5; | Check existence. | PHP |
if data = 99 then
print('value')
end | if data == 99 then
print('value')
end | Use ==. | Lua |
for i=1,53 do print(i) end | for i=1,53 do print(i) end | Correct. | Lua |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
let bar = 60; bar += 1; | let mut bar = 60; bar += 1; | Need mut to modify. | Rust |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
values(99) | if length(values) >= 99, values(99), end | Check length. | MATLAB |
<hr></hr> | <hr> | Self-closing. | HTML |
let mut data=3; let r1=&mut data; let r2=&mut data; | let mut data=3; {{ let r1=&mut data; }} let r2=&mut data; | Only one mutable borrow. | Rust |
JOIN orders ON items.id = orders.id | JOIN orders ON items.id = orders.id | Correct. | SQL |
if b = 28 | if b == 28 | Use ==. | MATLAB |
for (x in items) | for (x of items) | for...in iterates keys. | JavaScript |
val item: Int = 'value' | val item: String = 'value' | Fix type. | Kotlin |
'41' + 51 | 41 + 51 | Avoid string coercion. | JavaScript |
let item = 59; | let item = 59; | Correct. | JavaScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
const temp = 88; temp = 45; | let temp = 88; temp = 45; | Cannot reassign const. | JavaScript |
UPDATE items SET age='info' WHERE role=24 | UPDATE items SET age='info' WHERE role=24; | Add semicolon. | SQL |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
values[67] | if values.indices.contains(67) {{ values[67] }} | Check index. | Swift |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
items[92] | if (items.indices.contains(92)) items[92] | Check index. | Kotlin |
{{'age':'test'}} | {{"age":"test"}} | Use double quotes. | JSON |
if temp > 24
puts 'world' | if temp > 24
puts 'world'
end | Add 'end'. | Ruby |
with open('input.csv') as fh:
data = fh.read() | with open('input.csv') as fh:
data = fh.read() | Correct. | Python |
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 |
<p>value <b>world</p></b> | <p>value <b>world</b></p> | Nest properly. | HTML |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
if (x = 42) {{}} | if (x === 42) {{}} | Use === for equality. | JavaScript |
if y = 62 | if y == 62 | Use ==. | Go |
while val > 72
val -= 1 | while val > 72:
val -= 1 | Colon missing after while. | Python |
91x = 10 | x91 = 10 | Variable cannot start with digit. | Python |
if z = 96 {{}} | if z == 96 {{}} | Use ==. | Swift |
<br></br> | <br> | Self-closing. | HTML |
<table><tr><td>data<td>hello</tr></table> | <table><tr><td>data</td><td>hello</td></tr></table> | Close td. | HTML |
List(17,69,44) | List(17,69,44) | Correct. | Scala |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.