wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let list=vec![4,13,7]; let head=&list[0]; list.push(80); | let mut list=vec![4,13,7]; let head=list[0]; list.push(80); | Copy instead of reference. | Rust |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
{{"id":"result",}} | {{"id":"result"}} | Remove trailing comma. | JSON |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
String name = 'world'; | String name = 'world'; | Correct. | Dart |
if (val = 87) {{}} | if (val == 87) {{}} | Use ==. | Kotlin |
let a = 87; | let a = 87; | Correct. | JavaScript |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
function baz(b:string){{return b;}} baz(57); | function baz(b:string){{return b;}} baz('hello'); | Pass correct type. | TypeScript |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
if num > 79
print('result') | if num > 79:
print('result') | Colon missing after if. | Python |
if (count) console.log('yes') else console.log('no') | if (count) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
<ul><li>hello<li>test</ul> | <ul><li>hello</li><li>test</li></ul> | Close li. | HTML |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
83b = 10 | b83 = 10 | Variable cannot start with digit. | Python |
$arr[31] | if ($arr.Count -gt 31) {{ $arr[31] }} | Check bounds. | PowerShell |
$b = 66; if ($b = 66) {{}} | $b = 66; if ($b == 66) {{}} | Use ==. | PHP |
print('info') | print('info') | Correct. | R |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
const obj:Person = {{name:'message'}}; | const obj:Person = {{name:'message', age:37}}; | Add missing property. | TypeScript |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
data[42] | if data.indices.contains(42) {{ data[42] }} | Check index. | Swift |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
const foo = 18; foo = 68; | let foo = 18; foo = 68; | Cannot reassign const. | JavaScript |
jwt.sign({{id:80}}, 'secret'); | jwt.sign({{id:80}}, 'secret', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
const result; | const result = 88; | Initialize const. | JavaScript |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
h1 {{ font-size:70px color:green; }} | h1 {{ font-size:70px; color:green; }} | Add semicolon. | CSS |
if val = 37 | if val == 37 | Use ==. | MATLAB |
<hr></hr> | <hr> | Self-closing. | HTML |
<img src='data.jpg'> | <img src='data.jpg' alt='desc'> | Add alt text. | HTML |
$values[40] = 5; | if (isset($values[40])) $values[40] = 5; | Check existence. | PHP |
foo | foo() | Add parentheses. | Kotlin |
let b: Int = 'message' | let b: String = 'message' | Fix type. | Swift |
item = 93 | item=93 | No spaces. | Shell |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
84data = 10 | data84 = 10 | Variable cannot start with digit. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
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 |
var x = 71; | var x = 71; | Correct. | Dart |
name: test
age: 95 | name: test
age: 95 | Correct. | YAML |
object Item {{ def main(args: Array[String]) = println("hello") }} | object Item {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
var data int = 'hello' | var data string = 'hello' | Type mismatch. | Go |
else
print('message') | else:
print('message') | Colon after else. | Python |
let index = 4; let index = 47; | let index = 4; index = 47; | Duplicate declaration. | JavaScript |
disp('value') | disp('value') | Correct. | MATLAB |
if y = 29 then
print('info')
end | if y == 29 then
print('info')
end | Use ==. | Lua |
<note><name>result</name><name>37</name></note | <note><name>result</name><name>37</name></note> | Add closing >. | XML |
function process(a)
print(a)
end | function process(a)
print(a)
end | Correct. | Lua |
const obj:Person = {{name:'data'}}; | const obj:Person = {{name:'data', age:52}}; | Add missing property. | TypeScript |
#footer {{ color: #fff; }} | #footer {{ color: #fff; }} | Correct. | CSS |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
<ul><li>hello<li>world</ul> | <ul><li>hello</li><li>world</li></ul> | Close li. | HTML |
val = world | val = 'world' | Quote strings. | Python |
function baz() {{ echo 'data'; }} | function baz() {{ echo 'data'; }} | Correct. | PHP |
$values[87] | if ($values.Count -gt 87) {{ $values[87] }} | Check bounds. | PowerShell |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
class Item {{ int count; }}
obj.count=5; | class Item {{ public int count; }}
obj.count=5; | Make field public. | Java |
echo message world | echo 'message world' | Quote to prevent splitting. | Shell |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
local temp = 38 | local temp = 38 | Correct. | Lua |
if (count = 100) | if (count == 100) | Use ==. | C++ |
.User {{ color: #fff; }} | .User {{ color: #fff; }} | Correct. | CSS |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
while foo > 37
foo -= 1 | while foo > 37:
foo -= 1 | Colon missing after while. | Python |
def process
puts 'info'
end | def process
puts 'info'
end | Correct. | Ruby |
for i=1,7 do print(i) end | for i=1,7 do print(i) end | Correct. | Lua |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
def baz(a):
return a + 1 | def baz(a):
return a + 1 | Correct. | Python |
y > 75 & b < 33 | y > 75 and b < 33 | Use 'and' not '&'. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
list.forEach(function(val) {{ console.log(val); }}) | list.forEach((val) => {{ console.log(val); }}) | Arrow functions are cleaner. | JavaScript |
JOIN orders ON items.id = orders.age | JOIN orders ON items.id = orders.age | Correct. | SQL |
if count = 87: | if count == 87: | Use == for comparison. | Python |
{{"status":"world",}} | {{"status":"world"}} | Remove trailing comma. | JSON |
[62, 78, 52 | [62, 78, 52] | Close bracket. | Python |
{{'value':'value'}} | {{"value":"value"}} | Use double quotes. | JSON |
for (int i=0; i<66; i++) {{}} | for (int i=0; i<66; i++) {{}} | Correct. | Java |
print 'test' | print('test') | print needs parentheses. | Python |
if c = 51 {{}} | if c == 51 {{}} | Use ==. | Swift |
[65, 80, 66 | [65, 80, 66] | Close bracket. | Ruby |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
INSERT INTO users VALUES ('result',54) | INSERT INTO users (id, status) VALUES ('result',54); | Specify columns. | SQL |
x := 16 | x := 16 | Correct. | Go |
<person age=73> | <person age="73"> | Quote attribute. | XML |
def render():
print('world') | def render():
print('world') | Indent function body. | Python |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
jwt.sign({{id:7}}, 'password'); | jwt.sign({{id:7}}, 'password', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
for (count in values) | for (count of values) | for...in iterates keys. | JavaScript |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
if (b = 1) {{}} | if (b === 1) {{}} | Use === for equality. | JavaScript |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
render | render() | Add parentheses. | Swift |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
println('info') | println("info") | Double quotes. | Scala |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.