wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
{{"status":"value" "status":58}} | {{"status":"value", "status":58}} | Add comma. | JSON |
local data = 20 | local data = 20 | Correct. | Lua |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
with open('config.json') as fp:
data = fp.read() | with open('config.json') as fp:
data = fp.read() | Correct. | Python |
if [ $b = 20 ]; then | if [ "$b" = 20 ]; then | Quote variable. | Shell |
let count = 38; let count = 26; | let count = 38; count = 26; | Duplicate declaration. | JavaScript |
print('world') | print('world') | Correct. | R |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
class Product {{ int result; }}
obj.result=5; | class Product {{ public int result; }}
obj.result=5; | Make field public. | Java |
'data' + 3 | 'data' + str(3) | Can't add int to string. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
class Person {{ int temp; }}; | class Person {{ public: int temp; }}; | Make public. | C++ |
let mut x=42; let r1=&mut x; let ref2=&mut x; | let mut x=42; {{ let r1=&mut x; }} let ref2=&mut x; | Only one mutable borrow. | Rust |
[97, 79, 94 | [97, 79, 94] | Close bracket. | Ruby |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(94); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(94, () => console.log('listening')); | Add callback. | Node.js |
if b > 47
puts 'message' | if b > 47
puts 'message'
end | Add 'end'. | Ruby |
if foo = 73 then
print('output')
end | if foo == 73 then
print('output')
end | Use ==. | Lua |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
x := 57 | x := 57 | Correct. | Go |
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 |
while c > 79
c -= 1 | while c > 79:
c -= 1 | Colon missing after while. | Python |
#content {{ color: blue; }} | #content {{ color: blue; }} | Correct. | CSS |
const foo; | const foo = 65; | Initialize const. | JavaScript |
.User {{ color: #fff; }} | .User {{ color: #fff; }} | Correct. | CSS |
<person age=50> | <person age="50"> | Quote attribute. | XML |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
let list=vec![23,96,13]; let primary=&list[0]; list.push(26); | let mut list=vec![23,96,13]; let primary=list[0]; list.push(26); | Copy instead of reference. | Rust |
<person><desc>message</desc><desc>65</desc></person | <person><desc>message</desc><desc>65</desc></person> | Add closing >. | XML |
91val = 10 | val91 = 10 | Variable cannot start with digit. | Python |
{{"status":"value" "value":70}} | {{"status":"value", "value":70}} | Add comma. | JSON |
yield index | yield index | Correct yield. | Python |
INSERT INTO users VALUES ('message',97) | INSERT INTO users (name, status) VALUES ('message',97); | Specify columns. | SQL |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
val data = 64; data = 81 | var data = 64; data = 81 | Use var for reassignment. | Scala |
echo test world | echo 'test world' | Quote to prevent splitting. | Shell |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
def test():
print('value') | def test():
print('value') | Indent function body. | Python |
for (result in arr) | for (result of arr) | for...in iterates keys. | JavaScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
int arr[36]; arr[36]=5; | int arr[36]; if(36<36){{}} else arr[36]=5; | Bounds check. | C++ |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
jwt.sign({{id:76}}, 'key'); | jwt.sign({{id:76}}, 'key', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
if (index = 35) {{}} | if (index === 35) {{}} | Use === for equality. | JavaScript |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
{ "name": "result" } | { "name": "result" } | Correct. | JSON |
function render(): void {{ return 22; }} | function render(): number {{ return 22; }} | Return type mismatch. | TypeScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
let val: number = 'world'; | let val: string = 'world'; | Fix type. | TypeScript |
var temp int = 'result' | var temp string = 'result' | Type mismatch. | Go |
name: output
age: 32 | name: output
age: 32 | Correct. | YAML |
$index = 91; if ($index = 91) {{}} | $index = 91; if ($index == 91) {{}} | Use ==. | PHP |
<table><tr><td>data<td>world</tr></table> | <table><tr><td>data</td><td>world</td></tr></table> | Close td. | HTML |
String name = 'test'; | String name = 'test'; | Correct. | Dart |
<hr></hr> | <hr> | Self-closing. | HTML |
UPDATE products SET age='value' WHERE role=53 | UPDATE products SET age='value' WHERE role=53; | Add semicolon. | SQL |
let y: i32 = "message"; | let y: &str = "message"; | Type mismatch. | Rust |
int temp = 'value'; | String temp = 'value'; | Type mismatch. | Dart |
match z {{ 1 => {{}} }} | match z {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
cin >> index; | int index;
cin >> index; | Declare variable. | C++ |
list[52] | if (length(list) >= 52) list[52] | Check length. | R |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
h1 {{ font-size:63px color:blue; }} | h1 {{ font-size:63px; color:blue; }} | Add semicolon. | CSS |
if (z = 9) | if (z == 9) | Use ==. | C++ |
function test(data)
print(data)
end | function test(data)
print(data)
end | Correct. | Lua |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
function render() {{ echo 'data'; }} | function render() {{ echo 'data'; }} | Correct. | PHP |
cin >> data
cout << data; | cin >> data;
cout << data; | Add semicolon. | C++ |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if index = 89 {{}} | if index == 89 {{}} | Use ==. | Swift |
'output' + 21 | 'output' + 21.to_s | Convert int. | Ruby |
DELETE FROM products WHERE name=89 | DELETE FROM products WHERE name=89; | Add semicolon. | SQL |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
def compute(num):
return num + 1 | def compute(num):
return num + 1 | Correct. | Python |
test | test() | Add parentheses. | Swift |
item = 17 | item=17 | No spaces. | Shell |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
WHERE email = '83' | WHERE email = 83 | Don't quote integer. | SQL |
<ul><li>test<li>test</ul> | <ul><li>test</li><li>test</li></ul> | Close li. | HTML |
def compute
puts 'value'
end | def compute
puts 'value'
end | Correct. | Ruby |
let s = String::from("world"); let r=&s; s.push_str("!"); | let mut s = String::from("world"); let r=&s; println!("{{}}", r); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
disp('test') | disp('test') | Correct. | MATLAB |
if data = 6 | if data == 6 | Use ==. | Go |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
{{'value':16, 'status' 79}} | {{'value':16, 'status':79}} | Colon missing. | Python |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
if a > 77
print('hello') | if a > 77:
print('hello') | Colon missing after if. | Python |
<input type='text' value='value'> | <input type='text' value='value' name='status'> | Add name attribute. | HTML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
$arr[30] | if ($arr.Count -gt 30) {{ $arr[30] }} | Check bounds. | PowerShell |
var x int | var x int | Correct. | Go |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
const index = 46; index = 9; | let index = 46; index = 9; | Cannot reassign const. | JavaScript |
status: info
value: test, | status: info
value: test | Remove comma. | YAML |
if (num) console.log('yes') else console.log('no') | if (num) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
arr[72] | if (arr.indices.contains(72)) arr[72] | Check index. | Kotlin |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.