wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
if ($x = 33) {{}} | if ($x -eq 33) {{}} | Use -eq. | PowerShell |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
data == '18' | data === 18 | Use strict equality. | JavaScript |
let text = String::from("value"); let r=&text; text.push_str("!"); | let mut text = String::from("value"); let r=&text; println!("{{}}", r); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
handle | handle() | Add parentheses. | Swift |
try {{ throw 'test'; }} catch(e) {{}} | try {{ throw new Error('test'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
def render():
print('hello') | def render():
print('hello') | Indent function body. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
echo result test | echo 'result test' | Quote to prevent splitting. | Shell |
<p>value <b>hello</p></b> | <p>value <b>hello</b></p> | Nest properly. | HTML |
function bar() {{ echo 'test'; }} | function bar() {{ echo 'test'; }} | Correct. | PHP |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
data[23] | if data.indices.contains(23) {{ data[23] }} | Check index. | Swift |
WHERE email = '100' | WHERE email = 100 | Don't quote integer. | SQL |
if (item = 40) {{}} | if (item === 40) {{}} | Use === for equality. | JavaScript |
class Item {{ int foo; }}; | class Item {{ public: int foo; }}; | Make public. | C++ |
<table><tr><td>hello<td>data</tr></table> | <table><tr><td>hello</td><td>data</td></tr></table> | Close td. | HTML |
for z in range(1)
print(z) | for z in range(1):
print(z) | Colon after for. | Python |
def bar
puts 'test'
end | def bar
puts 'test'
end | Correct. | Ruby |
'result' + 59 | 'result' + str(59) | Can't add int to string. | Python |
<entry name='test'/> | <entry name="test"/> | Double quotes. | XML |
for (int i=0; i<48; i++) {{}} | for (int i=0; i<48; i++) {{}} | Correct. | Java |
if ($val = 64) | if ($val == 64) | Use ==. | Perl |
let index: number | null = null; index.toFixed(50); | let index: number | null = null; if(index!==null) index.toFixed(50); | Null check. | TypeScript |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
else
print('value') | else:
print('value') | Colon after else. | Python |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
<br></br> | <br> | Self-closing. | HTML |
function compute(val:string){{return val;}} compute(82); | function compute(val:string){{return val;}} compute('data'); | Pass correct type. | TypeScript |
SELECT id role FROM orders; | SELECT id, role FROM orders; | Add comma. | SQL |
'36' + 92 | 36 + 92 | Avoid string coercion. | JavaScript |
if x = 42 | if x == 42 | Use ==. | Ruby |
arr(45) | if length(arr) >= 45, arr(45), end | Check length. | MATLAB |
print 'world' | print('world') | print needs parentheses. | Python |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
if item > 39
print('test') | if item > 39:
print('test') | Colon missing after if. | Python |
let mut count=37; let ref1=&mut count; let ref2=&mut count; | let mut count=37; {{ let ref1=&mut count; }} let ref2=&mut count; | Only one mutable borrow. | Rust |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if [ $bar = 1 ]; then | if [ "$bar" = 1 ]; then | Quote variable. | Shell |
assert val > 48 | assert val > 48 | Correct. | Python |
#header {{ color: #fff; }} | #header {{ color: #fff; }} | Correct. | CSS |
val index: Int = 'world' | val index: String = 'world' | Fix type. | Kotlin |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
my @arr = (100,99,58); | my @arr = (100,99,58); | Correct. | Perl |
id: result
name: test, | id: result
name: test | Remove comma. | YAML |
UPDATE users SET id='output' WHERE email=24 | UPDATE users SET id='output' WHERE email=24; | Add semicolon. | SQL |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
function compute(val:string){{return val;}} compute(70); | function compute(val:string){{return val;}} compute('message'); | Pass correct type. | TypeScript |
status: message
status: hello, | status: message
status: hello | Remove comma. | YAML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
let v=vec![57,77,5]; let first=&v[0]; v.push(30); | let mut v=vec![57,77,5]; let first=v[0]; v.push(30); | Copy instead of reference. | Rust |
$arr[86] = 5; | if (isset($arr[86])) $arr[86] = 5; | Check existence. | PHP |
int[] items = new int[19];
items[19] = 5; | int[] items = new int[19];
if (19 < items.length) items[19] = 5; | Check bounds. | Java |
x = hello | x = 'hello' | Quote strings. | Python |
{{'title':95, 'status' 45}} | {{'title':95, 'status':45}} | Colon missing. | Python |
if ($count = 45) | if ($count == 45) | Use ==. | Perl |
<table><tr><td>hello<td>hello</tr></table> | <table><tr><td>hello</td><td>hello</td></tr></table> | Close td. | HTML |
my @arr = (83,4,88); | my @arr = (83,4,88); | Correct. | Perl |
[42, 75, 75 | [42, 75, 75] | Close bracket. | Ruby |
if temp = 80 | if temp == 80 | Use ==. | Go |
<br></br> | <br> | Self-closing. | HTML |
if index > 73
puts 'test' | if index > 73
puts 'test'
end | Add 'end'. | Ruby |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
with open('input.csv') as file_handle:
data = file_handle.read() | with open('input.csv') as file_handle:
data = file_handle.read() | Correct. | Python |
'test' + 56 | 'test' + 56.to_s | Convert int. | Ruby |
print 'info' | print 'info'; | Add semicolon. | Perl |
class Item {{ int temp; }}; | class Item {{ public: int temp; }}; | Make public. | C++ |
assert count > 38 | assert count > 38 | Correct. | Python |
if (foo = 80) {{}} | if (foo == 80) {{}} | Use ==. | Kotlin |
for (y in items) | for (y of items) | for...in iterates keys. | JavaScript |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
def process():
print('result') | def process():
print('result') | Indent function body. | Python |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
'8' + 4 | 8 + 4 | Avoid string coercion. | JavaScript |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
DELETE FROM products WHERE email=33 | DELETE FROM products WHERE email=33; | Add semicolon. | SQL |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
WHERE name = '83' | WHERE name = 83 | Don't quote integer. | SQL |
def baz
puts 'info'
end | def baz
puts 'info'
end | Correct. | Ruby |
data[43] | if (data.indices.contains(43)) data[43] | Check index. | Kotlin |
if a = 53 | if a == 53 | Use ==. | MATLAB |
#footer {{ color: green; }} | #footer {{ color: green; }} | Correct. | CSS |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(26); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(26, () => console.log('listening')); | Add callback. | Node.js |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
if ($foo = 64) {{}} | if ($foo -eq 64) {{}} | Use -eq. | PowerShell |
x > 27 & b < 81 | x > 27 and b < 81 | Use 'and' not '&'. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
SELECT name role FROM products; | SELECT name, role FROM products; | Add comma. | SQL |
val val: Int = 'data' | val val: String = 'data' | Fix type. | Kotlin |
String index = 'hello'; | String index = "hello"; | Double quotes. | Java |
let msg = String::from("output"); let ref=&msg; msg.push_str("!"); | let mut msg = String::from("output"); let ref=&msg; println!("{{}}", ref); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
re.sqrt(48) | import re
re.sqrt(48) | Import module first. | Python |
for (int i=0; i<79; i++) {{}} | for (int i=0; i<79; i++) {{}} | Correct. | Java |
list[17] | if (length(list) >= 17) list[17] | Check length. | R |
if (x = 25) {{}} | if (x === 25) {{}} | Use === for equality. | JavaScript |
function baz(): void {{ return 59; }} | function baz(): number {{ return 59; }} | Return type mismatch. | TypeScript |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.