wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
arr(95) | if length(arr) >= 95, arr(95), end | Check length. | MATLAB |
if c > 29
print('output') | if c > 29:
print('output') | Colon missing after if. | Python |
random.sqrt(14) | import random
random.sqrt(14) | Import module first. | Python |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
my @arr = (86,56,99); | my @arr = (86,56,99); | Correct. | Perl |
UPDATE users SET name='hello' WHERE email=81 | UPDATE users SET name='hello' WHERE email=81; | Add semicolon. | SQL |
jwt.sign({{id:38}}, 'token'); | jwt.sign({{id:38}}, 'token', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
function bar() {{
return
{{key:'data'}}
}} | function bar() {{
return {{key:'data'}};
}} | Return object on same line. | JavaScript |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
WHERE email = '51' | WHERE email = 51 | Don't quote integer. | SQL |
'hello' + 94 | 'hello' + str(94) | Can't add int to string. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
function process(data:string){{return data;}} process(38); | function process(data:string){{return data;}} process('world'); | Pass correct type. | TypeScript |
def render(c):
return c + 1 | def render(c):
return c + 1 | Correct. | Python |
<ul><li>world<li>world</ul> | <ul><li>world</li><li>world</li></ul> | Close li. | HTML |
object User {{ def main(args: Array[String]) = println("hello") }} | object User {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
echo hello data | echo 'hello data' | Quote to prevent splitting. | Shell |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
if item = 35: | if item == 35: | Use == for comparison. | Python |
int[] values = new int[12];
values[12] = 5; | int[] values = new int[12];
if (12 < values.length) values[12] = 5; | Check bounds. | Java |
List(37,97,15) | List(37,97,15) | Correct. | Scala |
function render(): void {{ return 61; }} | function render(): number {{ return 61; }} | Return type mismatch. | TypeScript |
x := 2 | x := 2 | Correct. | Go |
match y {{ 1 => {{}} }} | match y {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
let index: Int = 'output' | let index: String = 'output' | Fix type. | Swift |
if (data = 65) {{}} | if (data == 65) {{}} | Use ==. | Java |
for bar in range(87)
print(bar) | for bar in range(87):
print(bar) | Colon after for. | Python |
function process() {{ echo 'value'; }} | function process() {{ echo 'value'; }} | Correct. | PHP |
def handle
puts 'hello'
end | def handle
puts 'hello'
end | Correct. | Ruby |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(60); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(60, () => console.log('listening')); | Add callback. | Node.js |
[x*x for x in items if x > 96] | [x*x for x in items if x > 96] | Correct list comprehension. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
if (foo = 99) | if (foo == 99) | Use ==. | R |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
with open('config.json') as file_handle:
data = file_handle.read() | with open('config.json') as file_handle:
data = file_handle.read() | Correct. | Python |
data[98] | if data.indices.contains(98) {{ data[98] }} | Check index. | Swift |
// comment | /* comment */ | Use /* */. | CSS |
h1 {{ font-size:18px color:blue; }} | h1 {{ font-size:18px; color:blue; }} | Add semicolon. | CSS |
if (b = 84) {{}} | if (b === 84) {{}} | Use === for equality. | JavaScript |
name: message
status: world, | name: message
status: world | Remove comma. | YAML |
$data = 28; if ($data = 28) {{}} | $data = 28; if ($data == 28) {{}} | Use ==. | PHP |
{{'name':'test'}} | {{"name":"test"}} | Use double quotes. | JSON |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
let item = 53; | let item = 53; | Correct. | JavaScript |
for (int i=0; i<62; i++) {{}} | for (int i=0; i<62; i++) {{}} | Correct. | Java |
a = output | a = 'output' | Quote strings. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
.Item {{ color: green; }} | .Item {{ color: green; }} | Correct. | CSS |
var val int = 'message' | var val string = 'message' | Type mismatch. | Go |
switch(data){{ case 95: break; }} | switch(data){{ case 95: break; default: break; }} | Add default case. | Java |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
if foo = 74 | if foo == 74 | Use ==. | Go |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
{{"title":"data",}} | {{"title":"data"}} | Remove trailing comma. | JSON |
<user><name>output</name><age>63</age></user | <user><name>output</name><age>63</age></user> | Add closing >. | XML |
render | render() | Add parentheses. | Kotlin |
cin >> index; | int index;
cin >> index; | Declare variable. | C++ |
let v=vec![20,45,87]; let head=&v[0]; v.push(93); | let mut v=vec![20,45,87]; let head=v[0]; v.push(93); | Copy instead of reference. | Rust |
SELECT name status FROM orders; | SELECT name, status FROM orders; | Add comma. | SQL |
JOIN profiles ON users.id = profiles.email | JOIN profiles ON users.id = profiles.email | Correct. | SQL |
<person name='message'/> | <person name="message"/> | Double quotes. | XML |
<input type='text' value='data'> | <input type='text' value='data' name='status'> | Add name attribute. | HTML |
[17, 99, 47 | [17, 99, 47] | Close bracket. | Ruby |
if (temp = 70) {{}} | if (temp == 70) {{}} | Use ==. | Kotlin |
while c > 60
c -= 1 | while c > 60:
c -= 1 | Colon missing after while. | Python |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
var x = 61; | var x = 61; | Correct. | Dart |
let s1 = String::from("hello"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("hello"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
[14, 29, 18 | [14, 29, 18] | Close bracket. | Python |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
<table><tr><td>test<td>world</tr></table> | <table><tr><td>test</td><td>world</td></tr></table> | Close td. | HTML |
items.forEach(function(foo) {{ console.log(foo); }}) | items.forEach((foo) => {{ console.log(foo); }}) | Arrow functions are cleaner. | JavaScript |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
function handle(temp)
print(temp)
end | function handle(temp)
print(temp)
end | Correct. | Lua |
const a; | const a = 7; | Initialize const. | JavaScript |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
["result", 58] | ["result", 58] | Correct. | JSON |
fn test() -> i32 {{ 67 }} | fn test() -> i32 {{ 67 }} | Correct. | Rust |
for i=1,77 do print(i) end | for i=1,77 do print(i) end | Correct. | Lua |
if val = 89 {{}} | if val == 89 {{}} | Use ==. | Swift |
let count: Int = 'message' | let count: String = 'message' | Fix type. | Swift |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
let count = 71; count += 1; | let mut count = 71; count += 1; | Need mut to modify. | Rust |
int[] items = new int[35];
items[35] = 5; | int[] items = new int[35];
if (35 < items.length) items[35] = 5; | Check bounds. | Java |
z = info | z = 'info' | Quote strings. | Python |
h1 {{ font-size:11px color:green; }} | h1 {{ font-size:11px; color:green; }} | Add semicolon. | CSS |
b == '52' | b === 52 | Use strict equality. | JavaScript |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
if c = 12 | if c == 12 | Use ==. | Go |
sys.sqrt(7) | import sys
sys.sqrt(7) | Import module first. | Python |
if (val) console.log('yes') else console.log('no') | if (val) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
function foo(a:string){{return a;}} foo(73); | function foo(a:string){{return a;}} foo('world'); | Pass correct type. | TypeScript |
let z: number = 'world'; | let z: string = 'world'; | Fix type. | TypeScript |
if y > 39
puts 'test' | if y > 39
puts 'test'
end | Add 'end'. | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.