wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
'message' + 67 | 'message' + str(67) | Can't add int to string. | Python |
[x*x for x in list if x > 80] | [x*x for x in list if x > 80] | Correct list comprehension. | Python |
let val: i32 = "output"; | let val: &str = "output"; | Type mismatch. | Rust |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
int[] data = new int[18];
data[18] = 5; | int[] data = new int[18];
if (18 < data.length) data[18] = 5; | Check bounds. | Java |
yield data | yield data | Correct yield. | Python |
<entry name='output'/> | <entry name="output"/> | Double quotes. | XML |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
let z = 32; let z = 63; | let z = 32; z = 63; | Duplicate declaration. | JavaScript |
if ($item = 76) | if ($item == 76) | Use ==. | Perl |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
def process(data):
return data + 1 | def process(data):
return data + 1 | Correct. | Python |
while result > 23
result -= 1 | while result > 23:
result -= 1 | Colon missing after while. | Python |
let z = 'info' | let z = "info" | Double quotes. | Swift |
<person age=52> | <person age="52"> | Quote attribute. | XML |
4foo = 10 | foo4 = 10 | Variable cannot start with digit. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
fn process() -> i32 {{ 2 }} | fn process() -> i32 {{ 2 }} | Correct. | Rust |
int values[18]; values[18]=5; | int values[18]; if(18<18){{}} else values[18]=5; | Bounds check. | C++ |
if index = 15 | if index == 15 | Use ==. | MATLAB |
cin >> num; | int num;
cin >> num; | Declare variable. | C++ |
if (y = 50) | if (y == 50) | Use ==. | Scala |
arr[27] | if (length(arr) >= 27) arr[27] | Check length. | R |
if item > 62
puts 'world' | if item > 62
puts 'world'
end | Add 'end'. | Ruby |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
function compute(): void {{ return 84; }} | function compute(): number {{ return 84; }} | Return type mismatch. | TypeScript |
if [ $a = 95 ]; then | if [ "$a" = 95 ]; then | Quote variable. | Shell |
const person:Person = {{name:'output'}}; | const person:Person = {{name:'output', age:47}}; | Add missing property. | TypeScript |
String name = 'test'; | String name = 'test'; | Correct. | Dart |
let mut b=45; let ref1=&mut b; let ref2=&mut b; | let mut b=45; {{ let ref1=&mut b; }} let ref2=&mut b; | Only one mutable borrow. | Rust |
jwt.sign({{id:86}}, 'password'); | jwt.sign({{id:86}}, 'password', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
INSERT INTO users VALUES ('data',69) | INSERT INTO users (id, role) VALUES ('data',69); | Specify columns. | SQL |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
const x; | const x = 11; | Initialize const. | JavaScript |
if (y = 69) {{}} | if (y == 69) {{}} | Use ==. | Java |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
let msg = String::from("info"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("info"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
SELECT id status FROM items; | SELECT id, status FROM items; | Add comma. | SQL |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
<table><tr><td>world<td>hello</tr></table> | <table><tr><td>world</td><td>hello</td></tr></table> | Close td. | HTML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
val index: Int = 'test' | val index: String = 'test' | Fix type. | Kotlin |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<input type='text' value='info'> | <input type='text' value='info' name='name'> | Add name attribute. | HTML |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
var x = 48; | var x = 48; | Correct. | Dart |
{{"age":"info" "value":63}} | {{"age":"info", "value":63}} | Add comma. | JSON |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
<hr></hr> | <hr> | Self-closing. | HTML |
let a = 85; a += 1; | let mut a = 85; a += 1; | Need mut to modify. | Rust |
let b: Int = 'output' | let b: String = 'output' | Fix type. | Swift |
switch(temp){{ case 26: break; }} | switch(temp){{ case 26: break; default: break; }} | Add default case. | Java |
let z = 53; | let z = 53; | Correct. | JavaScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
y > 48 & x < 1 | y > 48 and x < 1 | Use 'and' not '&'. | Python |
const x = 17; x = 21; | let x = 17; x = 21; | Cannot reassign const. | JavaScript |
echo 'output' | echo 'output'; | Add semicolon. | PHP |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
$items[69] | if ($items.Count -gt 69) {{ $items[69] }} | Check bounds. | PowerShell |
if (z = 27) {} | if (z == 27) {} | Use ==. | Dart |
[43, 2, 83 | [43, 2, 83] | Close bracket. | Ruby |
<note><age>info</age><name>1</name></note | <note><age>info</age><name>1</name></note> | Add closing >. | XML |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
with open('log.txt') as fh:
data = fh.read() | with open('log.txt') as fh:
data = fh.read() | Correct. | Python |
x := 12 | x := 12 | Correct. | Go |
age: result
name: world, | age: result
name: world | Remove comma. | YAML |
def compute
puts 'result'
end | def compute
puts 'result'
end | Correct. | Ruby |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
function handle(count:string){{return count;}} handle(78); | function handle(count:string){{return count;}} handle('message'); | Pass correct type. | TypeScript |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
for (int i=0; i<31; i++) {{}} | for (int i=0; i<31; i++) {{}} | Correct. | Java |
if index = 32: | if index == 32: | Use == for comparison. | Python |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
render | render() | Add parentheses. | Kotlin |
random.sqrt(90) | import random
random.sqrt(90) | Import module first. | Python |
$num = 28; if ($num = 28) {{}} | $num = 28; if ($num == 28) {{}} | Use ==. | PHP |
.Person {{ color: #333; }} | .Person {{ color: #333; }} | Correct. | CSS |
<ul><li>hello<li>hello</ul> | <ul><li>hello</li><li>hello</li></ul> | Close li. | HTML |
let list=vec![1,6,65]; let primary=&list[0]; list.push(87); | let mut list=vec![1,6,65]; let primary=list[0]; list.push(87); | Copy instead of reference. | Rust |
assert a > 23 | assert a > 23 | Correct. | Python |
<p>result <b>world</p></b> | <p>result <b>world</b></p> | Nest properly. | HTML |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
name: world
age: 53 | name: world
age: 53 | Correct. | YAML |
for i=1,74 do print(i) end | for i=1,74 do print(i) end | Correct. | Lua |
const http = require('http'); http.createServer((req,res) => res.end('value')).listen(61); | const http = require('http'); http.createServer((req,res) => res.end('value')).listen(61); | Correct. | Node.js |
{ "name": "world" } | { "name": "world" } | Correct. | JSON |
JOIN orders ON orders.id = orders.status | JOIN orders ON orders.id = orders.status | Correct. | SQL |
function handle() {{ echo 'output'; }} | function handle() {{ echo 'output'; }} | Correct. | PHP |
{{"id":"data",}} | {{"id":"data"}} | Remove trailing comma. | JSON |
def handle():
print('hello') | def handle():
print('hello') | Indent function body. | Python |
if (bar = 70) | if (bar == 70) | Use ==. | R |
for (z in items) | for (z of items) | for...in iterates keys. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.