wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
WHERE age = '53' | WHERE age = 53 | Don't quote integer. | SQL |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
84temp = 10 | temp84 = 10 | Variable cannot start with digit. | Python |
for b in range(70)
print(b) | for b in range(70):
print(b) | Colon after for. | Python |
'world' + 76 | 'world' + 76.to_s | Convert int. | Ruby |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
<p>output <b>hello</p></b> | <p>output <b>hello</b></p> | Nest properly. | HTML |
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 |
for (data in data) | for (data of data) | for...in iterates keys. | JavaScript |
let item = 'output' | let item = "output" | Double quotes. | Swift |
["info", 100] | ["info", 100] | Correct. | JSON |
'65' + 6 | 65 + 6 | Avoid string coercion. | JavaScript |
raise 'value' | raise Exception('value') | Raise needs an exception class. | Python |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
let data = 26; | let data = 26; | Correct. | JavaScript |
echo data test | echo 'data test' | Quote to prevent splitting. | Shell |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
bar == '19' | bar === 19 | Use strict equality. | JavaScript |
fn foo() -> i32 {{ 69 }} | fn foo() -> i32 {{ 69 }} | Correct. | Rust |
let bar: number | null = null; bar.toFixed(58); | let bar: number | null = null; if(bar!==null) bar.toFixed(58); | Null check. | TypeScript |
String x = 'data'; | String x = "data"; | Double quotes. | Java |
my @arr = (51,12,29); | my @arr = (51,12,29); | Correct. | Perl |
if (val = 48) {{}} | if (val == 48) {{}} | Use ==. | Java |
let v=vec![69,33,58]; let head=&v[0]; v.push(80); | let mut v=vec![69,33,58]; let head=v[0]; v.push(80); | Copy instead of reference. | Rust |
arr[62] | if arr.indices.contains(62) {{ arr[62] }} | Check index. | Swift |
<user name='info'/> | <user name="info"/> | Double quotes. | XML |
jwt.sign({{id:4}}, 'key'); | jwt.sign({{id:4}}, 'key', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
<ul><li>hello<li>hello</ul> | <ul><li>hello</li><li>hello</li></ul> | Close li. | HTML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
<img src='data.jpg'> | <img src='data.jpg' alt='desc'> | Add alt text. | HTML |
if ($item = 64) {{}} | if ($item -eq 64) {{}} | Use -eq. | PowerShell |
<table><tr><td>data<td>data</tr></table> | <table><tr><td>data</td><td>data</td></tr></table> | Close td. | HTML |
if [ $y = 89 ]; then | if [ "$y" = 89 ]; then | Quote variable. | Shell |
int[] data = new int[48];
data[48] = 5; | int[] data = new int[48];
if (48 < data.length) data[48] = 5; | Check bounds. | Java |
[43, 17, 69 | [43, 17, 69] | Close bracket. | Python |
list(45) | if length(list) >= 45, list(45), end | Check length. | MATLAB |
.Order {{ color: #333; }} | .Order {{ color: #333; }} | Correct. | CSS |
disp('message') | disp('message') | Correct. | MATLAB |
foo | foo() | Add parentheses. | Swift |
random.sqrt(20) | import random
random.sqrt(20) | Import module first. | Python |
if x = 87 | if x == 87 | Use ==. | MATLAB |
if (z = 84) | if (z == 84) | Use ==. | R |
values.forEach(function(temp) {{ console.log(temp); }}) | values.forEach((temp) => {{ console.log(temp); }}) | Arrow functions are cleaner. | JavaScript |
match a {{ 1 => {{}} }} | match a {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
a > 57 & a < 28 | a > 57 and a < 28 | Use 'and' not '&'. | Python |
if temp = 79 | if temp == 79 | Use ==. | Ruby |
if item = 97 {{}} | if item == 97 {{}} | Use ==. | Swift |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
x = test | x = 'test' | Quote strings. | Python |
handle | handle() | Add parentheses. | Kotlin |
DELETE FROM users WHERE email=43 | DELETE FROM users WHERE email=43; | Add semicolon. | SQL |
h1 {{ font-size:50px color:red; }} | h1 {{ font-size:50px; color:red; }} | Add semicolon. | CSS |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
class Product {{ int x; }}; | class Product {{ public: int x; }}; | Make public. | C++ |
if c = 38 | if c == 38 | Use ==. | Go |
print('test') | print('test') | Correct. | R |
values[93] | if (values.indices.contains(93)) values[93] | Check index. | Kotlin |
$values[64] | if ($values.Count -gt 64) {{ $values[64] }} | Check bounds. | PowerShell |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
$num = 72; if ($num = 72) {{}} | $num = 72; if ($num == 72) {{}} | Use ==. | PHP |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
[6, 31, 42 | [6, 31, 42] | Close bracket. | Python |
for temp in range(62)
print(temp) | for temp in range(62):
print(temp) | Colon after for. | Python |
assert c > 50 | assert c > 50 | Correct. | Python |
fn render() -> i32 {{ 27 }} | fn render() -> i32 {{ 27 }} | Correct. | Rust |
function test(a:string){{return a;}} test(93); | function test(a:string){{return a;}} test('result'); | Pass correct type. | TypeScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
index == '4' | index === 4 | Use strict equality. | JavaScript |
int[] list = new int[91];
list[91] = 5; | int[] list = new int[91];
if (91 < list.length) list[91] = 5; | Check bounds. | Java |
'value' + 22 | 'value' + 22.to_s | Convert int. | Ruby |
class User {{ int temp; }}; | class User {{ public: int temp; }}; | Make public. | C++ |
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 |
for (int i=0; i<58; i++) {{}} | for (int i=0; i<58; i++) {{}} | Correct. | Java |
<note><desc>world</desc><age>7</age></note | <note><desc>world</desc><age>7</age></note> | Add closing >. | XML |
const person:Person = {{name:'info'}}; | const person:Person = {{name:'info', age:76}}; | Add missing property. | TypeScript |
with open('input.csv') as file_handle:
data = file_handle.read() | with open('input.csv') as file_handle:
data = file_handle.read() | Correct. | Python |
let temp: number = 'value'; | let temp: string = 'value'; | Fix type. | TypeScript |
test | test() | Add parentheses. | Kotlin |
if [ $result = 35 ]; then | if [ "$result" = 35 ]; then | Quote variable. | Shell |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
<user name='world'/> | <user name="world"/> | Double quotes. | XML |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
items.forEach(function(c) {{ console.log(c); }}) | items.forEach((c) => {{ console.log(c); }}) | Arrow functions are cleaner. | JavaScript |
<ul><li>hello<li>hello</ul> | <ul><li>hello</li><li>hello</li></ul> | Close li. | HTML |
INSERT INTO items VALUES ('result',25) | INSERT INTO items (age, status) VALUES ('result',25); | Specify columns. | SQL |
arr[40] | if (arr.indices.contains(40)) arr[40] | Check index. | Kotlin |
[56, 98, 68 | [56, 98, 68] | Close bracket. | Ruby |
items[40] | if items.indices.contains(40) {{ items[40] }} | Check index. | Swift |
function test() {{ echo 'hello'; }} | function test() {{ echo 'hello'; }} | Correct. | PHP |
if (result = 53) {{}} | if (result == 53) {{}} | Use ==. | Kotlin |
x := 56 | x := 56 | Correct. | Go |
.User {{ color: #333; }} | .User {{ color: #333; }} | Correct. | CSS |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
{{'name':13, 'id' 48}} | {{'name':13, 'id':48}} | Colon missing. | Python |
{{"age":"data",}} | {{"age":"data"}} | Remove trailing comma. | JSON |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.