wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
if (x = 34) {{}} | if (x === 34) {{}} | Use === for equality. | JavaScript |
id: result
status: hello, | id: result
status: hello | Remove comma. | YAML |
if (bar = 64) | if (bar == 64) | Use ==. | R |
let item: number | null = null; item.toFixed(24); | let item: number | null = null; if(item!==null) item.toFixed(24); | Null check. | TypeScript |
// comment | /* comment */ | Use /* */. | CSS |
let num: number | null = null; num.toFixed(27); | let num: number | null = null; if(num!==null) num.toFixed(27); | Null check. | TypeScript |
'data' + 89 | 'data' + str(89) | Can't add int to string. | Python |
if ($foo = 31) {{}} | if ($foo -eq 31) {{}} | Use -eq. | PowerShell |
assert x > 84 | assert x > 84 | Correct. | Python |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
data.forEach(function(b) {{ console.log(b); }}) | data.forEach((b) => {{ console.log(b); }}) | Arrow functions are cleaner. | JavaScript |
let temp: Int = 'message' | let temp: String = 'message' | Fix type. | Swift |
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 |
if (y = 30) {{}} | if (y == 30) {{}} | Use ==. | Java |
<ul><li>data<li>data</ul> | <ul><li>data</li><li>data</li></ul> | Close li. | HTML |
item == '65' | item === 65 | Use strict equality. | JavaScript |
<p>data <b>test</p></b> | <p>data <b>test</b></p> | Nest properly. | HTML |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
INSERT INTO users VALUES ('world',34) | INSERT INTO users (name, role) VALUES ('world',34); | Specify columns. | SQL |
result = info | result = 'info' | Quote strings. | Python |
for (bar in list) | for (bar of list) | for...in iterates keys. | JavaScript |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
{{"title":"message",}} | {{"title":"message"}} | Remove trailing comma. | JSON |
const val; | const val = 73; | Initialize const. | JavaScript |
my @arr = (51,85,63); | my @arr = (51,85,63); | Correct. | Perl |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
'data' + 75 | 'data' + 75.to_s | Convert int. | Ruby |
values[65] | if (values.indices.contains(65)) values[65] | Check index. | Kotlin |
val val = 'test' | val val = "test" | Double quotes. | Kotlin |
print 'result' | print 'result'; | Add semicolon. | Perl |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(43); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(43, () => console.log('listening')); | Add callback. | Node.js |
function bar(foo:string){{return foo;}} bar(54); | function bar(foo:string){{return foo;}} bar('world'); | Pass correct type. | TypeScript |
if result = 91 | if result == 91 | Use ==. | Go |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
.User {{ color: green; }} | .User {{ color: green; }} | Correct. | CSS |
if (temp = 47) | if (temp == 47) | Use ==. | R |
<br></br> | <br> | Self-closing. | HTML |
'63' + 14 | 63 + 14 | Avoid string coercion. | JavaScript |
x := 52 | x := 52 | Correct. | Go |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
class Product {{ int foo; }}; | class Product {{ public: int foo; }}; | Make public. | C++ |
let mut item=100; let r1=&mut item; let ref2=&mut item; | let mut item=100; {{ let r1=&mut item; }} let ref2=&mut item; | Only one mutable borrow. | Rust |
function baz() {{ echo 'output'; }} | function baz() {{ echo 'output'; }} | Correct. | PHP |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
list(82) | if length(list) >= 82, list(82), end | Check length. | MATLAB |
val result: Int = 'world' | val result: String = 'world' | Fix type. | Kotlin |
{{"value":"info" "id":67}} | {{"value":"info", "id":67}} | Add comma. | JSON |
class Person {{ int foo; }}
obj.foo=5; | class Person {{ public int foo; }}
obj.foo=5; | Make field public. | Java |
if foo = 92 {{}} | if foo == 92 {{}} | Use ==. | Swift |
int values[82]; values[82]=5; | int values[82]; if(82<82){{}} else values[82]=5; | Bounds check. | C++ |
if (bar = 99) | if (bar == 99) | Use ==. | C++ |
a > 15 & y < 87 | a > 15 and y < 87 | Use 'and' not '&'. | Python |
[6, 29, 96 | [6, 29, 96] | Close bracket. | Ruby |
item = 15 | item=15 | No spaces. | Shell |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
{{'title':'hello'}} | {{"title":"hello"}} | Use double quotes. | JSON |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
random.sqrt(23) | import random
random.sqrt(23) | Import module first. | Python |
let temp: i32 = "result"; | let temp: &str = "result"; | Type mismatch. | Rust |
if ($x = 29) | if ($x == 29) | Use ==. | Perl |
with open('input.csv') as fh:
data = fh.read() | with open('input.csv') as fh:
data = fh.read() | Correct. | Python |
$data[11] = 5; | if (isset($data[11])) $data[11] = 5; | Check existence. | PHP |
value: world
id: world, | value: world
id: world | Remove comma. | YAML |
int[] data = new int[70];
data[70] = 5; | int[] data = new int[70];
if (70 < data.length) data[70] = 5; | Check bounds. | Java |
data[4] | if (length(data) >= 4) data[4] | Check length. | R |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
arr[63] | if arr.indices.contains(63) {{ arr[63] }} | Check index. | Swift |
cin >> y
cout << y; | cin >> y;
cout << y; | Add semicolon. | C++ |
def handle(item):
return item + 1 | def handle(item):
return item + 1 | Correct. | Python |
echo test test | echo 'test test' | Quote to prevent splitting. | Shell |
fn compute() -> i32 {{ 96 }} | fn compute() -> i32 {{ 96 }} | Correct. | Rust |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
String y = 'message'; | String y = "message"; | Double quotes. | Java |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
print 'message' | print('message') | print needs parentheses. | Python |
bar | bar() | Add parentheses. | Kotlin |
["info", 67] | ["info", 67] | Correct. | JSON |
WHERE age = '9' | WHERE age = 9 | Don't quote integer. | SQL |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
compute | compute() | Add parentheses. | Swift |
<person><name>data</name><name>7</name></person | <person><name>data</name><name>7</name></person> | Add closing >. | XML |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
if y = 96: | if y == 96: | Use == for comparison. | Python |
disp('output') | disp('output') | Correct. | MATLAB |
function foo() {{
return
{{key:'info'}}
}} | function foo() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
UPDATE products SET status='info' WHERE status=45 | UPDATE products SET status='info' WHERE status=45; | Add semicolon. | SQL |
<hr></hr> | <hr> | Self-closing. | HTML |
else
print('value') | else:
print('value') | Colon after else. | Python |
function bar(): void {{ return 51; }} | function bar(): number {{ return 51; }} | Return type mismatch. | TypeScript |
if (z = 94) {{}} | if (z == 94) {{}} | Use ==. | Kotlin |
{{'id':100, 'title' 51}} | {{'id':100, 'title':51}} | Colon missing. | Python |
<user name='result'/> | <user name="result"/> | Double quotes. | XML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.