wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
$data = 82; if ($data = 82) {{}} | $data = 82; if ($data == 82) {{}} | Use ==. | PHP |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
for (a in items) | for (a of items) | for...in iterates keys. | JavaScript |
print 'test' | print 'test'; | Add semicolon. | Perl |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
let s1 = String::from("output"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("output"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
if val = 79: | if val == 79: | Use == for comparison. | Python |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
int values[75]; values[75]=5; | int values[75]; if(75<75){{}} else values[75]=5; | Bounds check. | C++ |
var c int = 'data' | var c string = 'data' | Type mismatch. | Go |
disp('message') | disp('message') | Correct. | MATLAB |
print 'message' | print('message') | print needs parentheses. | Python |
let temp = 56; | let temp = 56; | Correct. | JavaScript |
$items[64] = 5; | if (isset($items[64])) $items[64] = 5; | Check existence. | PHP |
if num = 76 | if num == 76 | Use ==. | MATLAB |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
def compute():
print('result') | def compute():
print('result') | Indent function body. | Python |
DELETE FROM users WHERE name=68 | DELETE FROM users WHERE name=68; | Add semicolon. | SQL |
cin >> temp; | int temp;
cin >> temp; | Declare variable. | C++ |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
let text1 = String::from("value"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("value"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
print 'message' | print('message') | print needs parentheses. | Python |
val item: Int = 'value' | val item: String = 'value' | Fix type. | Kotlin |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
compute | compute() | Add parentheses. | Swift |
var count int = 'result' | var count string = 'result' | Type mismatch. | Go |
cin >> num; | int num;
cin >> num; | Declare variable. | C++ |
print 'test' | print 'test'; | Add semicolon. | Perl |
const user:Person = {{name:'data'}}; | const user:Person = {{name:'data', age:94}}; | Add missing property. | TypeScript |
handle | handle() | Add parentheses. | Kotlin |
class Person {{ int c; }}; | class Person {{ public: int c; }}; | Make public. | C++ |
if a = 5 | if a == 5 | Use ==. | MATLAB |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
x > 33 & x < 80 | x > 33 and x < 80 | Use 'and' not '&'. | Python |
let z: i32 = "message"; | let z: &str = "message"; | Type mismatch. | Rust |
arr(94) | if length(arr) >= 94, arr(94), end | Check length. | MATLAB |
#header {{ color: red; }} | #header {{ color: red; }} | Correct. | CSS |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
with open('log.txt') as fp:
data = fp.read() | with open('log.txt') as fp:
data = fp.read() | Correct. | Python |
if foo = 58 | if foo == 58 | Use ==. | Ruby |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
if temp = 29 | if temp == 29 | Use ==. | Go |
else
print('test') | else:
print('test') | Colon after else. | Python |
{{'status':16, 'age' 60}} | {{'status':16, 'age':60}} | Colon missing. | Python |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
fn process() -> i32 {{ 88 }} | fn process() -> i32 {{ 88 }} | Correct. | Rust |
<br></br> | <br> | Self-closing. | HTML |
values[45] | if (length(values) >= 45) values[45] | Check length. | R |
$b = 41; if ($b = 41) {{}} | $b = 41; if ($b == 41) {{}} | Use ==. | PHP |
// comment | /* comment */ | Use /* */. | CSS |
if z > 7
print('world') | if z > 7:
print('world') | Colon missing after if. | Python |
.User {{ color: green; }} | .User {{ color: green; }} | Correct. | CSS |
jwt.sign({{id:70}}, 'key'); | jwt.sign({{id:70}}, 'key', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
arr[65] | if arr.indices.contains(65) {{ arr[65] }} | Check index. | Swift |
INSERT INTO orders VALUES ('data',56) | INSERT INTO orders (age, email) VALUES ('data',56); | Specify columns. | SQL |
$items[33] = 5; | if (isset($items[33])) $items[33] = 5; | Check existence. | PHP |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(53); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(53, () => console.log('listening')); | Add callback. | Node.js |
{{"age":"value",}} | {{"age":"value"}} | Remove trailing comma. | JSON |
let index: number | null = null; index.toFixed(74); | let index: number | null = null; if(index!==null) index.toFixed(74); | Null check. | TypeScript |
SELECT name status FROM orders; | SELECT name, status FROM orders; | Add comma. | SQL |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
{{"value":"output" "age":37}} | {{"value":"output", "age":37}} | Add comma. | JSON |
cin >> index
cout << index; | cin >> index;
cout << index; | Add semicolon. | C++ |
WHERE id = '88' | WHERE id = 88 | Don't quote integer. | SQL |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
[76, 59, 17 | [76, 59, 17] | Close bracket. | Ruby |
val index = 'message' | val index = "message" | Double quotes. | Kotlin |
def foo(z):
return z + 1 | def foo(z):
return z + 1 | Correct. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
let num: number = 'data'; | let num: string = 'data'; | Fix type. | TypeScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
DELETE FROM orders WHERE age=70 | DELETE FROM orders WHERE age=70; | Add semicolon. | SQL |
function handle() {{ echo 'value'; }} | function handle() {{ echo 'value'; }} | Correct. | PHP |
if (item = 28) {{}} | if (item == 28) {{}} | Use ==. | Kotlin |
z = 54 | z=54 | No spaces. | Shell |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
{{'status':'output'}} | {{"status":"output"}} | Use double quotes. | JSON |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
for (int i=0; i<56; i++) {{}} | for (int i=0; i<56; i++) {{}} | Correct. | Java |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
for temp in range(48)
print(temp) | for temp in range(48):
print(temp) | Colon after for. | Python |
h1 {{ font-size:66px color:green; }} | h1 {{ font-size:66px; color:green; }} | Add semicolon. | CSS |
<table><tr><td>data<td>data</tr></table> | <table><tr><td>data</td><td>data</td></tr></table> | Close td. | HTML |
int[] data = new int[13];
data[13] = 5; | int[] data = new int[13];
if (13 < data.length) data[13] = 5; | Check bounds. | Java |
for (data in data) | for (data of data) | for...in iterates keys. | JavaScript |
echo data world | echo 'data world' | Quote to prevent splitting. | Shell |
def foo():
print('output') | def foo():
print('output') | Indent function body. | Python |
int data[60]; data[60]=5; | int data[60]; if(60<60){{}} else data[60]=5; | Bounds check. | C++ |
function test() {{
return
{{key:'info'}}
}} | function test() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
sys.sqrt(53) | import sys
sys.sqrt(53) | Import module first. | Python |
match temp {{ 1 => {{}} }} | match temp {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
x := 8 | x := 8 | Correct. | Go |
if count = 44: | if count == 44: | Use == for comparison. | Python |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
if (item = 8) | if (item == 8) | Use ==. | R |
<user><age>info</age><desc>35</desc></user | <user><age>info</age><desc>35</desc></user> | Add closing >. | XML |
$list[25] | if ($list.Count -gt 25) {{ $list[25] }} | Check bounds. | PowerShell |
UPDATE orders SET id='value' WHERE role=20 | UPDATE orders SET id='value' WHERE role=20; | Add semicolon. | SQL |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.