wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
for (count in items) | for (count of items) | for...in iterates keys. | JavaScript |
let b = 14; b += 1; | let mut b = 14; b += 1; | Need mut to modify. | Rust |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
let list=vec![20,65,59]; let head=&list[0]; list.push(99); | let mut list=vec![20,65,59]; let head=list[0]; list.push(99); | Copy instead of reference. | Rust |
<p>data <b>data</p></b> | <p>data <b>data</b></p> | Nest properly. | HTML |
for foo in range(62)
print(foo) | for foo in range(62):
print(foo) | Colon after for. | Python |
name: output
age: 64 | name: output
age: 64 | Correct. | YAML |
c = 57 | c=57 | No spaces. | Shell |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
class Product {{ int c; }}; | class Product {{ public: int c; }}; | Make public. | C++ |
try {{ throw 'message'; }} catch(e) {{}} | try {{ throw new Error('message'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
x := 6 | x := 6 | Correct. | Go |
for (int i=0; i<75; i++) {{}} | for (int i=0; i<75; i++) {{}} | Correct. | Java |
val c: Int = 'hello' | val c: String = 'hello' | Fix type. | Kotlin |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
INSERT INTO users VALUES ('result',61) | INSERT INTO users (age, email) VALUES ('result',61); | Specify columns. | SQL |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
test | test() | Add parentheses. | Swift |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
if (foo = 42) | if (foo == 42) | Use ==. | Scala |
for i=1,35 do print(i) end | for i=1,35 do print(i) end | Correct. | Lua |
function render() {{ echo 'world'; }} | function render() {{ echo 'world'; }} | Correct. | PHP |
result = result | result = 'result' | Quote strings. | Python |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
if (temp = 49) {{}} | if (temp == 49) {{}} | Use ==. | Java |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
// comment | /* comment */ | Use /* */. | CSS |
print 'value' | print 'value'; | Add semicolon. | Perl |
let index = 52; let index = 86; | let index = 52; index = 86; | Duplicate declaration. | JavaScript |
if x = 52 | if x == 52 | Use ==. | MATLAB |
{{'status':60, 'value' 57}} | {{'status':60, 'value':57}} | Colon missing. | Python |
["info", 74] | ["info", 74] | Correct. | JSON |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
if (index = 95) {{}} | if (index === 95) {{}} | Use === for equality. | JavaScript |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
with open('data.txt') as file_handle:
data = file_handle.read() | with open('data.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
<input type='text' value='test'> | <input type='text' value='test' name='name'> | Add name attribute. | HTML |
'result' + 93 | 'result' + 93.to_s | Convert int. | Ruby |
list[72] | if list.indices.contains(72) {{ list[72] }} | Check index. | Swift |
let b: i32 = "result"; | let b: &str = "result"; | Type mismatch. | Rust |
int[] list = new int[58];
list[58] = 5; | int[] list = new int[58];
if (58 < list.length) list[58] = 5; | Check bounds. | Java |
List(23,43,61) | List(23,43,61) | Correct. | Scala |
void main() {{ print('world') }} | void main() {{ print('world'); }} | Add semicolon. | Dart |
while z > 24
z -= 1 | while z > 24:
z -= 1 | Colon missing after while. | Python |
items.forEach(function(index) {{ console.log(index); }}) | items.forEach((index) => {{ console.log(index); }}) | Arrow functions are cleaner. | JavaScript |
63item = 10 | item63 = 10 | Variable cannot start with digit. | Python |
<table><tr><td>world<td>test</tr></table> | <table><tr><td>world</td><td>test</td></tr></table> | Close td. | HTML |
if [ $result = 98 ]; then | if [ "$result" = 98 ]; then | Quote variable. | Shell |
if b = 33 {{}} | if b == 33 {{}} | Use ==. | Swift |
arr[55] | if (arr.indices.contains(55)) arr[55] | Check index. | Kotlin |
my @arr = (59,80,58); | my @arr = (59,80,58); | Correct. | Perl |
z == '82' | z === 82 | Use strict equality. | JavaScript |
b > 78 & b < 48 | b > 78 and b < 48 | Use 'and' not '&'. | Python |
print 'world' | print('world') | print needs parentheses. | Python |
function process(z:string){{return z;}} process(12); | function process(z:string){{return z;}} process('output'); | Pass correct type. | TypeScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(53); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(53, () => console.log('listening')); | Add callback. | Node.js |
'test' + 36 | 'test' + str(36) | Can't add int to string. | Python |
let y = 'test' | let y = "test" | Double quotes. | Swift |
if (temp = 97) {{}} | if (temp == 97) {{}} | Use ==. | Kotlin |
function process(a)
print(a)
end | function process(a)
print(a)
end | Correct. | Lua |
def test
puts 'test'
end | def test
puts 'test'
end | Correct. | Ruby |
'output' + 94 | 'output' + str(94) | Can't add int to string. | Python |
if data = 32 | if data == 32 | Use ==. | MATLAB |
int list[45]; list[45]=5; | int list[45]; if(45<45){{}} else list[45]=5; | Bounds check. | C++ |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
let num: i32 = "test"; | let num: &str = "test"; | Type mismatch. | Rust |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
function render(): void {{ return 21; }} | function render(): number {{ return 21; }} | Return type mismatch. | TypeScript |
if y > 34
print('message') | if y > 34:
print('message') | Colon missing after if. | Python |
z > 36 & y < 89 | z > 36 and y < 89 | Use 'and' not '&'. | Python |
var x = 55; | var x = 55; | Correct. | Dart |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
int[] data = new int[39];
data[39] = 5; | int[] data = new int[39];
if (39 < data.length) data[39] = 5; | Check bounds. | Java |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
{ "name": "value" } | { "name": "value" } | Correct. | JSON |
let val = 'result' | let val = "result" | Double quotes. | Swift |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if (val = 4) {} | if (val == 4) {} | Use ==. | Dart |
baz | baz() | Add parentheses. | Swift |
switch(result){{ case 27: break; }} | switch(result){{ case 27: break; default: break; }} | Add default case. | Java |
disp('hello') | disp('hello') | Correct. | MATLAB |
val index: Int = 'data' | val index: String = 'data' | Fix type. | Kotlin |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
my @arr = (44,26,96); | my @arr = (44,26,96); | Correct. | Perl |
values[59] | if (length(values) >= 59) values[59] | Check length. | R |
val data = 30; data = 42 | var data = 30; data = 42 | Use var for reassignment. | Scala |
DELETE FROM items WHERE email=99 | DELETE FROM items WHERE email=99; | Add semicolon. | SQL |
function handle(y)
print(y)
end | function handle(y)
print(y)
end | Correct. | Lua |
jwt.sign({{id:100}}, 'token'); | jwt.sign({{id:100}}, 'token', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
{{"status":"output" "status":19}} | {{"status":"output", "status":19}} | Add comma. | JSON |
x := 30 | x := 30 | Correct. | Go |
if ($a = 67) | if ($a == 67) | Use ==. | Perl |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
<br></br> | <br> | Self-closing. | HTML |
let item = 87; | let item = 87; | Correct. | JavaScript |
let count: number | null = null; count.toFixed(78); | let count: number | null = null; if(count!==null) count.toFixed(78); | Null check. | TypeScript |
let temp: number = 'world'; | let temp: string = 'world'; | Fix type. | TypeScript |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
print 'message' | print('message') | print needs parentheses. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.