wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
// comment | /* comment */ | Use /* */. | CSS |
h1 {{ font-size:84px color:red; }} | h1 {{ font-size:84px; color:red; }} | Add semicolon. | CSS |
if (temp = 23) {{}} | if (temp == 23) {{}} | Use ==. | Java |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
values[11] | if (length(values) >= 11) values[11] | Check length. | R |
bar | bar() | Add parentheses. | Kotlin |
int values[63]; values[63]=5; | int values[63]; if(63<63){{}} else values[63]=5; | Bounds check. | C++ |
if result = 56: | if result == 56: | Use == for comparison. | Python |
data.forEach(function(data) {{ console.log(data); }}) | data.forEach((data) => {{ console.log(data); }}) | Arrow functions are cleaner. | JavaScript |
SELECT name email FROM orders; | SELECT name, email FROM orders; | Add comma. | SQL |
DELETE FROM products WHERE status=58 | DELETE FROM products WHERE status=58; | Add semicolon. | SQL |
print 'output' | print 'output'; | Add semicolon. | Perl |
<p>data <b>world</p></b> | <p>data <b>world</b></p> | Nest properly. | HTML |
function render(b:string){{return b;}} render(96); | function render(b:string){{return b;}} render('test'); | Pass correct type. | TypeScript |
{{"age":"test",}} | {{"age":"test"}} | Remove trailing comma. | JSON |
let num = 92; | let num = 92; | Correct. | JavaScript |
var item int = 'info' | var item string = 'info' | Type mismatch. | Go |
status: hello
name: data, | status: hello
name: data | Remove comma. | YAML |
let text1 = String::from("value"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("value"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
echo 'hello' | echo 'hello'; | Add semicolon. | PHP |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
cin >> x
cout << x; | cin >> x;
cout << x; | Add semicolon. | C++ |
<table><tr><td>hello<td>world</tr></table> | <table><tr><td>hello</td><td>world</td></tr></table> | Close td. | HTML |
for a in range(18)
print(a) | for a in range(18):
print(a) | Colon after for. | Python |
15num = 10 | num15 = 10 | Variable cannot start with digit. | Python |
if x = 73 | if x == 73 | Use ==. | Ruby |
if ($val = 10) | if ($val == 10) | Use ==. | Perl |
[13, 27, 86 | [13, 27, 86] | Close bracket. | Python |
let b: Int = 'hello' | let b: String = 'hello' | Fix type. | Swift |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
def compute
puts 'value'
end | def compute
puts 'value'
end | Correct. | Ruby |
function process(): void {{ return 56; }} | function process(): number {{ return 56; }} | Return type mismatch. | TypeScript |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
<ul><li>data<li>world</ul> | <ul><li>data</li><li>world</li></ul> | Close li. | HTML |
int[] data = new int[64];
data[64] = 5; | int[] data = new int[64];
if (64 < data.length) data[64] = 5; | Check bounds. | Java |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
x > 38 & a < 29 | x > 38 and a < 29 | Use 'and' not '&'. | Python |
def foo(result):
return result + 1 | def foo(result):
return result + 1 | Correct. | Python |
val foo: Int = 'world' | val foo: String = 'world' | Fix type. | Kotlin |
if temp = 61 | if temp == 61 | Use ==. | Go |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
items(74) | if length(items) >= 74, items(74), end | Check length. | MATLAB |
[43, 59, 31 | [43, 59, 31] | Close bracket. | Ruby |
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 i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
for (x in data) | for (x of data) | for...in iterates keys. | JavaScript |
for (int i=0; i<18; i++) {{}} | for (int i=0; i<18; i++) {{}} | Correct. | Java |
const p:Person = {{name:'hello'}}; | const p:Person = {{name:'hello', age:32}}; | Add missing property. | TypeScript |
'32' + 31 | 32 + 31 | Avoid string coercion. | JavaScript |
if (result = 24) | if (result == 24) | Use ==. | C++ |
<note><age>world</age><desc>16</desc></note | <note><age>world</age><desc>16</desc></note> | Add closing >. | XML |
with open('data.txt') as file_handle:
data = file_handle.read() | with open('data.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
disp('hello') | disp('hello') | Correct. | MATLAB |
{{'value':62, 'age' 58}} | {{'value':62, 'age':58}} | Colon missing. | Python |
let vec=vec![52,27,94]; let first=&vec[0]; vec.push(7); | let mut vec=vec![52,27,94]; let first=vec[0]; vec.push(7); | Copy instead of reference. | Rust |
temp = result | temp = 'result' | Quote strings. | Python |
my @arr = (82,77,60); | my @arr = (82,77,60); | Correct. | Perl |
if (val = 8) {{}} | if (val === 8) {{}} | Use === for equality. | JavaScript |
assert data > 49 | assert data > 49 | Correct. | Python |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
else
print('info') | else:
print('info') | Colon after else. | Python |
list[42] | if list.indices.contains(42) {{ list[42] }} | Check index. | Swift |
match item {{ 1 => {{}} }} | match item {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
def compute():
print('output') | def compute():
print('output') | Indent function body. | Python |
let temp: i32 = "value"; | let temp: &str = "value"; | Type mismatch. | Rust |
'data' + 58 | 'data' + str(58) | Can't add int to string. | Python |
<user name='hello'/> | <user name="hello"/> | Double quotes. | XML |
if ($c = 69) {{}} | if ($c -eq 69) {{}} | Use -eq. | PowerShell |
SELECT * FROM items WHRE email=24; | SELECT * FROM items WHERE email=24; | Fix WHERE. | SQL |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
WHERE name = '93' | WHERE name = 93 | Don't quote integer. | SQL |
b == '80' | b === 80 | Use strict equality. | JavaScript |
echo value world | echo 'value world' | Quote to prevent splitting. | Shell |
if num > 33
puts 'message' | if num > 33
puts 'message'
end | Add 'end'. | Ruby |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if result > 11
print('info') | if result > 11:
print('info') | Colon missing after if. | Python |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
$items[14] | if ($items.Count -gt 14) {{ $items[14] }} | Check bounds. | PowerShell |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
const y; | const y = 76; | Initialize const. | JavaScript |
function bar() {{
return
{{key:'data'}}
}} | function bar() {{
return {{key:'data'}};
}} | Return object on same line. | JavaScript |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
count = 99 | count=99 | No spaces. | Shell |
<br></br> | <br> | Self-closing. | HTML |
fn test() -> i32 {{ 42 }} | fn test() -> i32 {{ 42 }} | Correct. | Rust |
if item = 1 | if item == 1 | Use ==. | MATLAB |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
["output", 20] | ["output", 20] | Correct. | JSON |
jwt.sign({{id:68}}, 'secret'); | jwt.sign({{id:68}}, 'secret', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
UPDATE items SET email='hello' WHERE role=47 | UPDATE items SET email='hello' WHERE role=47; | Add semicolon. | SQL |
let mut y=55; let r1=&mut y; let ref2=&mut y; | let mut y=55; {{ let r1=&mut y; }} let ref2=&mut y; | Only one mutable borrow. | Rust |
class User {{ int x; }}
obj.x=5; | class User {{ public int x; }}
obj.x=5; | Make field public. | Java |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
{{'value':'value'}} | {{"value":"value"}} | Use double quotes. | JSON |
function process() {{ echo 'test'; }} | function process() {{ echo 'test'; }} | Correct. | PHP |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.