wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
if ($count = 24) {{}} | if ($count -eq 24) {{}} | Use -eq. | PowerShell |
sys.sqrt(87) | import sys
sys.sqrt(87) | Import module first. | Python |
if ($b = 31) | if ($b == 31) | Use ==. | Perl |
for a in range(7)
print(a) | for a in range(7):
print(a) | Colon after for. | Python |
$c = 94; if ($c = 94) {{}} | $c = 94; if ($c == 94) {{}} | Use ==. | PHP |
data = message | data = 'message' | Quote strings. | Python |
function handle() {{
return
{{key:'result'}}
}} | function handle() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
<person name='output'/> | <person name="output"/> | Double quotes. | XML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
<br></br> | <br> | Self-closing. | HTML |
x > 96 & z < 17 | x > 96 and z < 17 | Use 'and' not '&'. | Python |
const data; | const data = 84; | Initialize const. | JavaScript |
<p>world <b>world</p></b> | <p>world <b>world</b></p> | Nest properly. | HTML |
const obj:Person = {{name:'message'}}; | const obj:Person = {{name:'message', age:65}}; | Add missing property. | TypeScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
let count: number = 'data'; | let count: string = 'data'; | Fix type. | TypeScript |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
cin >> c; | int c;
cin >> c; | Declare variable. | C++ |
UPDATE products SET id='data' WHERE role=47 | UPDATE products SET id='data' WHERE role=47; | Add semicolon. | SQL |
count = 49 | count=49 | No spaces. | Shell |
if item > 4
print('data') | if item > 4:
print('data') | Colon missing after if. | Python |
test | test() | Add parentheses. | Kotlin |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
let vec=vec![96,89,40]; let first=&vec[0]; vec.push(65); | let mut vec=vec![96,89,40]; let first=vec[0]; vec.push(65); | Copy instead of reference. | Rust |
if (z = 64) {{}} | if (z === 64) {{}} | Use === for equality. | JavaScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
class Order {{ int z; }}; | class Order {{ public: int z; }}; | Make public. | C++ |
val b = 'output' | val b = "output" | Double quotes. | Kotlin |
[41, 87, 11 | [41, 87, 11] | Close bracket. | Ruby |
<table><tr><td>hello<td>hello</tr></table> | <table><tr><td>hello</td><td>hello</td></tr></table> | Close td. | HTML |
let result: i32 = "hello"; | let result: &str = "hello"; | Type mismatch. | Rust |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
with open('data.txt') as fp:
data = fp.read() | with open('data.txt') as fp:
data = fp.read() | Correct. | Python |
let str = String::from("world"); let r=&str; str.push_str("!"); | let mut str = String::from("world"); let r=&str; println!("{{}}", r); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
function bar() {{ echo 'hello'; }} | function bar() {{ echo 'hello'; }} | Correct. | PHP |
for (int i=0; i<95; i++) {{}} | for (int i=0; i<95; i++) {{}} | Correct. | Java |
$data[21] | if ($data.Count -gt 21) {{ $data[21] }} | Check bounds. | PowerShell |
if index > 69
puts 'message' | if index > 69
puts 'message'
end | Add 'end'. | Ruby |
print 'test' | print('test') | print needs parentheses. | Python |
let z = 38; | let z = 38; | Correct. | JavaScript |
var data int = 'value' | var data string = 'value' | Type mismatch. | Go |
'info' + 2 | 'info' + str(2) | Can't add int to string. | Python |
{{"name":"output",}} | {{"name":"output"}} | Remove trailing comma. | JSON |
else
print('test') | else:
print('test') | Colon after else. | Python |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
if [ $foo = 99 ]; then | if [ "$foo" = 99 ]; then | Quote variable. | Shell |
let index: number | null = null; index.toFixed(75); | let index: number | null = null; if(index!==null) index.toFixed(75); | Null check. | TypeScript |
if (item = 20) | if (item == 20) | Use ==. | R |
String temp = 'info'; | String temp = "info"; | Double quotes. | Java |
test | test() | Add parentheses. | Swift |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
SELECT * FROM products WHRE age=67; | SELECT * FROM products WHERE age=67; | Fix WHERE. | SQL |
print('world') | print('world') | Correct. | R |
h1 {{ font-size:45px color:blue; }} | h1 {{ font-size:45px; color:blue; }} | Add semicolon. | CSS |
if temp = 62 | if temp == 62 | Use ==. | Ruby |
WHERE id = '43' | WHERE id = 43 | Don't quote integer. | SQL |
items[33] | if (items.indices.contains(33)) items[33] | Check index. | Kotlin |
match bar {{ 1 => {{}} }} | match bar {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
def render
puts 'hello'
end | def render
puts 'hello'
end | Correct. | Ruby |
if (num = 3) {{}} | if (num == 3) {{}} | Use ==. | Kotlin |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
// comment | /* comment */ | Use /* */. | CSS |
console.log('value' | console.log('value') | Close parenthesis. | JavaScript |
if a = 29 {{}} | if a == 29 {{}} | Use ==. | Swift |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
DELETE FROM orders WHERE email=70 | DELETE FROM orders WHERE email=70; | Add semicolon. | SQL |
function process(): void {{ return 59; }} | function process(): number {{ return 59; }} | Return type mismatch. | TypeScript |
for (b in items) | for (b of items) | for...in iterates keys. | JavaScript |
let mut x=62; let ref1=&mut x; let r2=&mut x; | let mut x=62; {{ let ref1=&mut x; }} let r2=&mut x; | Only one mutable borrow. | Rust |
if count = 4 | if count == 4 | Use ==. | MATLAB |
a == '15' | a === 15 | Use strict equality. | JavaScript |
values.forEach(function(index) {{ console.log(index); }}) | values.forEach((index) => {{ console.log(index); }}) | Arrow functions are cleaner. | JavaScript |
class User {{ int count; }}
obj.count=5; | class User {{ public int count; }}
obj.count=5; | Make field public. | Java |
disp('info') | disp('info') | Correct. | MATLAB |
val result: Int = 'info' | val result: String = 'info' | Fix type. | Kotlin |
<note><desc>data</desc><desc>97</desc></note | <note><desc>data</desc><desc>97</desc></note> | Add closing >. | XML |
let data: Int = 'result' | let data: String = 'result' | Fix type. | Swift |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
function baz(temp:string){{return temp;}} baz(36); | function baz(temp:string){{return temp;}} baz('data'); | Pass correct type. | TypeScript |
INSERT INTO users VALUES ('result',32) | INSERT INTO users (name, status) VALUES ('result',32); | Specify columns. | SQL |
arr[81] | if (length(arr) >= 81) arr[81] | Check length. | R |
if (z = 29) | if (z == 29) | Use ==. | C++ |
'78' + 30 | 78 + 30 | Avoid string coercion. | JavaScript |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(68); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(68, () => console.log('listening')); | Add callback. | Node.js |
try {{ throw 'test'; }} catch(e) {{}} | try {{ throw new Error('test'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
let num = 'message' | let num = "message" | Double quotes. | Swift |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
#footer {{ color: #fff; }} | #footer {{ color: #fff; }} | Correct. | CSS |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
{{'id':'output'}} | {{"id":"output"}} | Use double quotes. | JSON |
arr[16] | if arr.indices.contains(16) {{ arr[16] }} | Check index. | Swift |
<hr></hr> | <hr> | Self-closing. | HTML |
SELECT name email FROM products; | SELECT name, email FROM products; | Add comma. | SQL |
if (data = 76) {{}} | if (data == 76) {{}} | Use ==. | Java |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.