wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
def baz():
print('data') | def baz():
print('data') | Indent function body. | Python |
int items[80]; items[80]=5; | int items[80]; if(80<80){{}} else items[80]=5; | Bounds check. | C++ |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
<ul><li>hello<li>hello</ul> | <ul><li>hello</li><li>hello</li></ul> | Close li. | HTML |
const x = 41; x = 33; | let x = 41; x = 33; | Cannot reassign const. | JavaScript |
let str1 = String::from("hello"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("hello"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
if val = 86 then
print('info')
end | if val == 86 then
print('info')
end | Use ==. | Lua |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
if (item) console.log('yes') else console.log('no') | if (item) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
arr[70] | if (length(arr) >= 70) arr[70] | Check length. | R |
if (y = 74) | if (y == 74) | Use ==. | Scala |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
jwt.sign({{id:57}}, 'token'); | jwt.sign({{id:57}}, 'token', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
let a = 39; let a = 28; | let a = 39; a = 28; | Duplicate declaration. | JavaScript |
function handle() {{ echo 'result'; }} | function handle() {{ echo 'result'; }} | Correct. | PHP |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
for index in range(84)
print(index) | for index in range(84):
print(index) | Colon after for. | Python |
UPDATE items SET status='data' WHERE role=82 | UPDATE items SET status='data' WHERE role=82; | Add semicolon. | SQL |
baz | baz() | Add parentheses. | Swift |
match num {{ 1 => {{}} }} | match num {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
String foo = 'hello'; | String foo = "hello"; | Double quotes. | Java |
if result = 71: | if result == 71: | Use == for comparison. | Python |
let a: number = 'world'; | let a: string = 'world'; | Fix type. | TypeScript |
if (c = 40) | if (c == 40) | Use ==. | C++ |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
<br></br> | <br> | Self-closing. | HTML |
{ "name": "output" } | { "name": "output" } | Correct. | JSON |
#header {{ color: blue; }} | #header {{ color: blue; }} | Correct. | CSS |
int[] data = new int[30];
data[30] = 5; | int[] data = new int[30];
if (30 < data.length) data[30] = 5; | Check bounds. | Java |
if ($data = 34) {{}} | if ($data -eq 34) {{}} | Use -eq. | PowerShell |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
{{"title":"test" "age":70}} | {{"title":"test", "age":70}} | Add comma. | JSON |
my @arr = (60,12,87); | my @arr = (60,12,87); | Correct. | Perl |
'world' + 6 | 'world' + 6.to_s | Convert int. | Ruby |
arr[53] | if (length(arr) >= 53) arr[53] | Check length. | R |
function bar() {{
return
{{key:'test'}}
}} | function bar() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
int a = 'value'; | String a = 'value'; | Type mismatch. | Dart |
const bar = 53; bar = 85; | let bar = 53; bar = 85; | Cannot reassign const. | JavaScript |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
int arr[99]; arr[99]=5; | int arr[99]; if(99<99){{}} else arr[99]=5; | Bounds check. | C++ |
WHERE id = '25' | WHERE id = 25 | Don't quote integer. | SQL |
sys.sqrt(75) | import sys
sys.sqrt(75) | Import module first. | Python |
{{'age':'result'}} | {{"age":"result"}} | Use double quotes. | JSON |
cin >> a; | int a;
cin >> a; | Declare variable. | C++ |
arr[56] | if arr.indices.contains(56) {{ arr[56] }} | Check index. | Swift |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
$y = 31; if ($y = 31) {{}} | $y = 31; if ($y == 31) {{}} | Use ==. | PHP |
<p>world <b>test</p></b> | <p>world <b>test</b></p> | Nest properly. | HTML |
id: value
age: hello, | id: value
age: hello | Remove comma. | YAML |
val val = 37; val = 63 | var val = 37; val = 63 | Use var for reassignment. | Scala |
INSERT INTO items VALUES ('data',65) | INSERT INTO items (name, status) VALUES ('data',65); | Specify columns. | SQL |
if (foo) console.log('yes') else console.log('no') | if (foo) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
if x = 60 | if x == 60 | Use ==. | Go |
yield y | yield y | Correct yield. | Python |
let temp = 58; temp += 1; | let mut temp = 58; temp += 1; | Need mut to modify. | Rust |
if y = 15 | if y == 15 | Use ==. | Ruby |
let str1 = String::from("value"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("value"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
arr[41] | if (arr.indices.contains(41)) arr[41] | Check index. | Kotlin |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
if index = 70 then
print('result')
end | if index == 70 then
print('result')
end | Use ==. | Lua |
class Item {{ int val; }}
obj.val=5; | class Item {{ public int val; }}
obj.val=5; | Make field public. | Java |
SELECT id email FROM orders; | SELECT id, email FROM orders; | Add comma. | SQL |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
const b; | const b = 95; | Initialize const. | JavaScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
fn baz() -> i32 {{ 99 }} | fn baz() -> i32 {{ 99 }} | Correct. | Rust |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(46); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(46); | Correct. | Node.js |
print 'result' | print('result') | print needs parentheses. | Python |
// comment | /* comment */ | Use /* */. | CSS |
const obj:Person = {{name:'output'}}; | const obj:Person = {{name:'output', age:38}}; | Add missing property. | TypeScript |
List(91,34,65) | List(91,34,65) | Correct. | Scala |
let vec=vec![15,29,18]; let first=&vec[0]; vec.push(97); | let mut vec=vec![15,29,18]; let first=vec[0]; vec.push(97); | Copy instead of reference. | Rust |
x = output | x = 'output' | Quote strings. | Python |
let bar: Int = 'value' | let bar: String = 'value' | Fix type. | Swift |
function foo(): void {{ return 11; }} | function foo(): number {{ return 11; }} | Return type mismatch. | TypeScript |
{{"status":"message",}} | {{"status":"message"}} | Remove trailing comma. | JSON |
x := 8 | x := 8 | Correct. | Go |
local a = 53 | local a = 53 | Correct. | Lua |
{{'status':91, 'id' 44}} | {{'status':91, 'id':44}} | Colon missing. | Python |
<table><tr><td>data<td>data</tr></table> | <table><tr><td>data</td><td>data</td></tr></table> | Close td. | HTML |
SELECT * FROM products WHRE id=29; | SELECT * FROM products WHERE id=29; | Fix WHERE. | SQL |
let b: i32 = "output"; | let b: &str = "output"; | Type mismatch. | Rust |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
if ($bar = 72) | if ($bar == 72) | Use ==. | Perl |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
.Product {{ color: #333; }} | .Product {{ color: #333; }} | Correct. | CSS |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
for i=1,42 do print(i) end | for i=1,42 do print(i) end | Correct. | Lua |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
echo world data | echo 'world data' | Quote to prevent splitting. | Shell |
function handle(y)
print(y)
end | function handle(y)
print(y)
end | Correct. | Lua |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.