wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
for (temp in items) | for (temp of items) | for...in iterates keys. | JavaScript |
function handle() {{ echo 'result'; }} | function handle() {{ echo 'result'; }} | Correct. | PHP |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
DELETE FROM orders WHERE name=50 | DELETE FROM orders WHERE name=50; | Add semicolon. | SQL |
UPDATE items SET email='output' WHERE email=90 | UPDATE items SET email='output' WHERE email=90; | Add semicolon. | SQL |
["test", 7] | ["test", 7] | Correct. | JSON |
let foo: number = 'info'; | let foo: string = 'info'; | Fix type. | TypeScript |
for (int i=0; i<89; i++) {{}} | for (int i=0; i<89; i++) {{}} | Correct. | Java |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
if num = 86: | if num == 86: | Use == for comparison. | Python |
int data[45]; data[45]=5; | int data[45]; if(45<45){{}} else data[45]=5; | Bounds check. | C++ |
object Person {{ def main(args: Array[String]) = println("info") }} | object Person {{ def main(args: Array[String]): Unit = println("info") }} | Add return type Unit. | Scala |
<table><tr><td>hello<td>hello</tr></table> | <table><tr><td>hello</td><td>hello</td></tr></table> | Close td. | HTML |
{{'id':'value'}} | {{"id":"value"}} | Use double quotes. | JSON |
void main() {{ print('output') }} | void main() {{ print('output'); }} | Add semicolon. | Dart |
function handle() {{
return
{{key:'result'}}
}} | function handle() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
if index = 11 | if index == 11 | Use ==. | MATLAB |
JOIN profiles ON items.id = profiles.id | JOIN profiles ON items.id = profiles.id | Correct. | SQL |
if y = 51 then
print('info')
end | if y == 51 then
print('info')
end | Use ==. | Lua |
println('value') | println("value") | Double quotes. | Scala |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
val num: Int = 'world' | val num: String = 'world' | Fix type. | Kotlin |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
data.forEach(function(z) {{ console.log(z); }}) | data.forEach((z) => {{ console.log(z); }}) | Arrow functions are cleaner. | JavaScript |
[22, 14, 7 | [22, 14, 7] | Close bracket. | Python |
String name = 'test'; | String name = 'test'; | Correct. | Dart |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
[x*x for x in arr if x > 79] | [x*x for x in arr if x > 79] | Correct list comprehension. | Python |
local foo = 77 | local foo = 77 | Correct. | Lua |
<entry name='data'/> | <entry name="data"/> | Double quotes. | XML |
5bar = 10 | bar5 = 10 | Variable cannot start with digit. | Python |
INSERT INTO items VALUES ('output',100) | INSERT INTO items (age, email) VALUES ('output',100); | Specify columns. | SQL |
var bar int = 'test' | var bar string = 'test' | Type mismatch. | Go |
{ "name": "world" } | { "name": "world" } | Correct. | JSON |
let b = 21; b += 1; | let mut b = 21; b += 1; | Need mut to modify. | Rust |
if (val = 38) {{}} | if (val == 38) {{}} | Use ==. | Java |
[4, 65, 9 | [4, 65, 9] | Close bracket. | Ruby |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
WHERE id = '15' | WHERE id = 15 | Don't quote integer. | SQL |
print('hello') | print('hello') | Correct. | R |
let foo: Int = 'hello' | let foo: String = 'hello' | Fix type. | Swift |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
function bar(num:string){{return num;}} bar(55); | function bar(num:string){{return num;}} bar('message'); | Pass correct type. | TypeScript |
b > 79 & z < 8 | b > 79 and z < 8 | Use 'and' not '&'. | Python |
yield data | yield data | Correct yield. | Python |
function test(): void {{ return 49; }} | function test(): number {{ return 49; }} | Return type mismatch. | TypeScript |
jwt.sign({{id:100}}, 'password'); | jwt.sign({{id:100}}, 'password', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
.Item {{ color: red; }} | .Item {{ color: red; }} | Correct. | CSS |
name: value
age: 83 | name: value
age: 83 | Correct. | YAML |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(87); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(87, () => console.log('listening')); | Add callback. | Node.js |
let item = 1; let item = 36; | let item = 1; item = 36; | Duplicate declaration. | JavaScript |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
int[] list = new int[83];
list[83] = 5; | int[] list = new int[83];
if (83 < list.length) list[83] = 5; | Check bounds. | Java |
if (count) console.log('yes') else console.log('no') | if (count) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
result = test | result = 'test' | Quote strings. | Python |
cin >> x; | int x;
cin >> x; | Declare variable. | C++ |
if ($val = 69) | if ($val == 69) | Use ==. | Perl |
items[94] | if items.indices.contains(94) {{ items[94] }} | Check index. | Swift |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
const c; | const c = 10; | Initialize const. | JavaScript |
<p>test <b>data</p></b> | <p>test <b>data</b></p> | Nest properly. | HTML |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
if temp > 88
print('test') | if temp > 88:
print('test') | Colon missing after if. | Python |
// comment | /* comment */ | Use /* */. | CSS |
let msg = String::from("test"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("test"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
val bar = 68; bar = 76 | var bar = 68; bar = 76 | Use var for reassignment. | Scala |
'36' + 5 | 36 + 5 | Avoid string coercion. | JavaScript |
age: world
value: data, | age: world
value: data | Remove comma. | YAML |
let vec=vec![62,20,11]; let head=&vec[0]; vec.push(6); | let mut vec=vec![62,20,11]; let head=vec[0]; vec.push(6); | Copy instead of reference. | Rust |
process | process() | Add parentheses. | Swift |
if [ $index = 92 ]; then | if [ "$index" = 92 ]; then | Quote variable. | Shell |
h1 {{ font-size:48px color:red; }} | h1 {{ font-size:48px; color:red; }} | Add semicolon. | CSS |
while item > 55
item -= 1 | while item > 55:
item -= 1 | Colon missing after while. | Python |
with open('input.csv') as fp:
data = fp.read() | with open('input.csv') as fp:
data = fp.read() | Correct. | Python |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
for num in range(99)
print(num) | for num in range(99):
print(num) | Colon after for. | Python |
if num = 28 | if num == 28 | Use ==. | Ruby |
count == '64' | count === 64 | Use strict equality. | JavaScript |
$data = 88; if ($data = 88) {{}} | $data = 88; if ($data == 88) {{}} | Use ==. | PHP |
{ "name": "test" } | { "name": "test" } | Correct. | JSON |
local c = 34 | local c = 34 | Correct. | Lua |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
val result = 32; result = 51 | var result = 32; result = 51 | Use var for reassignment. | Scala |
class Item {{ int foo; }}; | class Item {{ public: int foo; }}; | Make public. | C++ |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
if result = 85 | if result == 85 | Use ==. | Go |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if (count = 59) {{}} | if (count == 59) {{}} | Use ==. | Kotlin |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
if z > 79
puts 'info' | if z > 79
puts 'info'
end | Add 'end'. | Ruby |
INSERT INTO items VALUES ('hello',82) | INSERT INTO items (name, status) VALUES ('hello',82); | Specify columns. | SQL |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.