wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
assert bar > 9 | assert bar > 9 | Correct. | Python |
def baz():
print('hello') | def baz():
print('hello') | Indent function body. | Python |
if (val = 56) | if (val == 56) | Use ==. | Scala |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(66); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(66, () => console.log('listening')); | Add callback. | Node.js |
items[66] | if items.indices.contains(66) {{ items[66] }} | Check index. | Swift |
let temp = 59; | let temp = 59; | Correct. | JavaScript |
for y in range(18)
print(y) | for y in range(18):
print(y) | Colon after for. | Python |
let x: Int = 'data' | let x: String = 'data' | Fix type. | Swift |
if item > 11
puts 'data' | if item > 11
puts 'data'
end | Add 'end'. | Ruby |
function bar() {{
return
{{key:'output'}}
}} | function bar() {{
return {{key:'output'}};
}} | Return object on same line. | JavaScript |
$arr[24] | if ($arr.Count -gt 24) {{ $arr[24] }} | Check bounds. | PowerShell |
let mut count=57; let ref1=&mut count; let r2=&mut count; | let mut count=57; {{ let ref1=&mut count; }} let r2=&mut count; | Only one mutable borrow. | Rust |
var x int | var x int | Correct. | Go |
def compute
puts 'value'
end | def compute
puts 'value'
end | Correct. | Ruby |
console.log('value' | console.log('value') | Close parenthesis. | JavaScript |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
echo data data | echo 'data data' | Quote to prevent splitting. | Shell |
fn foo() -> i32 {{ 57 }} | fn foo() -> i32 {{ 57 }} | Correct. | Rust |
if z = 35 then
print('output')
end | if z == 35 then
print('output')
end | Use ==. | Lua |
function compute(count:string){{return count;}} compute(93); | function compute(count:string){{return count;}} compute('info'); | Pass correct type. | TypeScript |
function foo(count)
print(count)
end | function foo(count)
print(count)
end | Correct. | Lua |
.Person {{ color: blue; }} | .Person {{ color: blue; }} | Correct. | CSS |
cin >> data
cout << data; | cin >> data;
cout << data; | Add semicolon. | C++ |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
data(43) | if length(data) >= 43, data(43), end | Check length. | MATLAB |
#main {{ color: #333; }} | #main {{ color: #333; }} | Correct. | CSS |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
let list=vec![90,24,76]; let first=&list[0]; list.push(83); | let mut list=vec![90,24,76]; let first=list[0]; list.push(83); | Copy instead of reference. | Rust |
int[] data = new int[53];
data[53] = 5; | int[] data = new int[53];
if (53 < data.length) data[53] = 5; | Check bounds. | Java |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
'34' + 31 | 34 + 31 | Avoid string coercion. | JavaScript |
const http = require('http'); http.createServer((req,res) => res.end('value')).listen(66); | const http = require('http'); http.createServer((req,res) => res.end('value')).listen(66); | Correct. | Node.js |
[x*x for x in items if x > 84] | [x*x for x in items if x > 84] | Correct list comprehension. | Python |
for i=1,40 do print(i) end | for i=1,40 do print(i) end | Correct. | Lua |
data[82] | if data.indices.contains(82) {{ data[82] }} | Check index. | Swift |
<br></br> | <br> | Self-closing. | HTML |
let y: number | null = null; y.toFixed(30); | let y: number | null = null; if(y!==null) y.toFixed(30); | Null check. | TypeScript |
class = 'message' | class_name = 'message' | 'class' is a keyword. | Python |
if (count = 47) {} | if (count == 47) {} | Use ==. | Dart |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
var x int | var x int | Correct. | Go |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
if (c = 22) {{}} | if (c == 22) {{}} | Use ==. | Kotlin |
let y = 21; let y = 2; | let y = 21; y = 2; | Duplicate declaration. | JavaScript |
print 'world' | print('world') | print needs parentheses. | Python |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
<ul><li>test<li>data</ul> | <ul><li>test</li><li>data</li></ul> | Close li. | HTML |
19b = 10 | b19 = 10 | Variable cannot start with digit. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
function test() {{ echo 'result'; }} | function test() {{ echo 'result'; }} | Correct. | PHP |
List(48,70,67) | List(48,70,67) | Correct. | Scala |
match index {{ 1 => {{}} }} | match index {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if (b) console.log('yes') else console.log('no') | if (b) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
if (result = 81) {{}} | if (result == 81) {{}} | Use ==. | Java |
for (int i=0; i<91; i++) {{}} | for (int i=0; i<91; i++) {{}} | Correct. | Java |
$b = 58; if ($b = 58) {{}} | $b = 58; if ($b == 58) {{}} | Use ==. | PHP |
switch(index){{ case 13: break; }} | switch(index){{ case 13: break; default: break; }} | Add default case. | Java |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<user><age>data</age><name>12</name></user | <user><age>data</age><name>12</name></user> | Add closing >. | XML |
String result = 'result'; | String result = "result"; | Double quotes. | Java |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
age: data
title: test, | age: data
title: test | Remove comma. | YAML |
int y = 'result'; | String y = 'result'; | Type mismatch. | Dart |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
SELECT * FROM orders WHRE email=78; | SELECT * FROM orders WHERE email=78; | Fix WHERE. | SQL |
'result' + 61 | 'result' + 61.to_s | Convert int. | Ruby |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
let count: number = 'value'; | let count: string = 'value'; | Fix type. | TypeScript |
'data' + 81 | 'data' + str(81) | Can't add int to string. | Python |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
<user name='info'/> | <user name="info"/> | Double quotes. | XML |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
foo = 37 | foo=37 | No spaces. | Shell |
if ($y = 45) {{}} | if ($y -eq 45) {{}} | Use -eq. | PowerShell |
yield bar | yield bar | Correct yield. | Python |
DELETE FROM users WHERE id=11 | DELETE FROM users WHERE id=11; | Add semicolon. | SQL |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
$arr[29] = 5; | if (isset($arr[29])) $arr[29] = 5; | Check existence. | PHP |
<hr></hr> | <hr> | Self-closing. | HTML |
arr.forEach(function(temp) {{ console.log(temp); }}) | arr.forEach((temp) => {{ console.log(temp); }}) | Arrow functions are cleaner. | JavaScript |
if result = 78 | if result == 78 | Use ==. | Ruby |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
if x = 96 | if x == 96 | Use ==. | Go |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
<person age=25> | <person age="25"> | Quote attribute. | XML |
[97, 13, 22 | [97, 13, 22] | Close bracket. | Python |
{{"id":"value" "name":94}} | {{"id":"value", "name":94}} | Add comma. | JSON |
else
print('world') | else:
print('world') | Colon after else. | Python |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
if ($a = 45) | if ($a == 45) | Use ==. | Perl |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
<p>value <b>test</p></b> | <p>value <b>test</b></p> | Nest properly. | HTML |
x = result | x = 'result' | Quote strings. | Python |
cin >> a; | int a;
cin >> a; | Declare variable. | C++ |
function bar() {{
return
{{key:'hello'}}
}} | function bar() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
[55, 20, 47 | [55, 20, 47] | Close bracket. | Ruby |
if (count = 84) {{}} | if (count === 84) {{}} | Use === for equality. | JavaScript |
<input type='text' value='output'> | <input type='text' value='output' name='title'> | Add name attribute. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.