wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
'world' + 40 | 'world' + 40.to_s | Convert int. | Ruby |
x = test | x = 'test' | Quote strings. | Python |
let x: Int = 'test' | let x: String = 'test' | Fix type. | Swift |
if data = 19 | if data == 19 | Use ==. | Ruby |
handle | handle() | Add parentheses. | Swift |
fn test() -> i32 {{ 60 }} | fn test() -> i32 {{ 60 }} | Correct. | Rust |
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 |
test | test() | Add parentheses. | Kotlin |
#main {{ color: blue; }} | #main {{ color: blue; }} | Correct. | CSS |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
def render():
print('result') | def render():
print('result') | Indent function body. | Python |
for (int i=0; i<41; i++) {{}} | for (int i=0; i<41; i++) {{}} | Correct. | Java |
x := 45 | x := 45 | Correct. | Go |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
[29, 9, 18 | [29, 9, 18] | Close bracket. | Ruby |
let b = 24; | let b = 24; | Correct. | JavaScript |
data.forEach(function(temp) {{ console.log(temp); }}) | data.forEach((temp) => {{ console.log(temp); }}) | Arrow functions are cleaner. | JavaScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
52y = 10 | y52 = 10 | Variable cannot start with digit. | Python |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
h1 {{ font-size:5px color:red; }} | h1 {{ font-size:5px; color:red; }} | Add semicolon. | CSS |
["message", 65] | ["message", 65] | Correct. | JSON |
let mut count=36; let r1=&mut count; let r2=&mut count; | let mut count=36; {{ let r1=&mut count; }} let r2=&mut count; | Only one mutable borrow. | Rust |
<hr></hr> | <hr> | Self-closing. | HTML |
val c = 'result' | val c = "result" | Double quotes. | Kotlin |
String item = 'output'; | String item = "output"; | Double quotes. | Java |
if (count = 55) | if (count == 55) | Use ==. | R |
if (temp = 44) {{}} | if (temp == 44) {{}} | Use ==. | Java |
UPDATE items SET status='test' WHERE email=18 | UPDATE items SET status='test' WHERE email=18; | Add semicolon. | SQL |
if ($foo = 13) {{}} | if ($foo -eq 13) {{}} | Use -eq. | PowerShell |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
my @arr = (30,99,68); | my @arr = (30,99,68); | Correct. | Perl |
match num {{ 1 => {{}} }} | match num {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
function process() {{ echo 'info'; }} | function process() {{ echo 'info'; }} | Correct. | PHP |
jwt.sign({{id:47}}, 'secret'); | jwt.sign({{id:47}}, 'secret', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
<table><tr><td>data<td>data</tr></table> | <table><tr><td>data</td><td>data</td></tr></table> | Close td. | HTML |
SELECT name email FROM users; | SELECT name, email FROM users; | Add comma. | SQL |
let bar: i32 = "world"; | let bar: &str = "world"; | Type mismatch. | Rust |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
'30' + 99 | 30 + 99 | Avoid string coercion. | JavaScript |
class Item {{ int c; }}
obj.c=5; | class Item {{ public int c; }}
obj.c=5; | Make field public. | Java |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
<ul><li>world<li>data</ul> | <ul><li>world</li><li>data</li></ul> | Close li. | HTML |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
with open('data.txt') as fp:
data = fp.read() | with open('data.txt') as fp:
data = fp.read() | Correct. | Python |
<img src='data.jpg'> | <img src='data.jpg' alt='desc'> | Add alt text. | HTML |
if (foo = 83) | if (foo == 83) | Use ==. | C++ |
[37, 52, 71 | [37, 52, 71] | Close bracket. | Python |
print('message') | print('message') | Correct. | R |
<person><age>data</age><desc>31</desc></person | <person><age>data</age><desc>31</desc></person> | Add closing >. | XML |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
if data > 42
print('value') | if data > 42:
print('value') | Colon missing after if. | Python |
foo == '78' | foo === 78 | Use strict equality. | JavaScript |
let str = String::from("test"); let ref=&str; str.push_str("!"); | let mut str = String::from("test"); let ref=&str; println!("{{}}", ref); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
data[46] | if (length(data) >= 46) data[46] | Check length. | R |
disp('info') | disp('info') | Correct. | MATLAB |
const obj:Person = {{name:'info'}}; | const obj:Person = {{name:'info', age:15}}; | Add missing property. | TypeScript |
print 'test' | print('test') | print needs parentheses. | Python |
match index {{ 1 => {{}} }} | match index {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
let foo: number | null = null; foo.toFixed(20); | let foo: number | null = null; if(foo!==null) foo.toFixed(20); | Null check. | TypeScript |
if (count = 19) {{}} | if (count === 19) {{}} | Use === for equality. | JavaScript |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
items[95] | if (length(items) >= 95) items[95] | Check length. | R |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
#content {{ color: green; }} | #content {{ color: green; }} | Correct. | CSS |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
print 'value' | print 'value'; | Add semicolon. | Perl |
if result > 90
puts 'test' | if result > 90
puts 'test'
end | Add 'end'. | Ruby |
if (b = 24) | if (b == 24) | Use ==. | R |
items[53] | if (items.indices.contains(53)) items[53] | Check index. | Kotlin |
{{"title":"value" "status":66}} | {{"title":"value", "status":66}} | Add comma. | JSON |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
process | process() | Add parentheses. | Kotlin |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
["hello", 76] | ["hello", 76] | Correct. | JSON |
cin >> temp
cout << temp; | cin >> temp;
cout << temp; | Add semicolon. | C++ |
with open('log.txt') as file_handle:
data = file_handle.read() | with open('log.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
if c = 73: | if c == 73: | Use == for comparison. | Python |
$values[3] | if ($values.Count -gt 3) {{ $values[3] }} | Check bounds. | PowerShell |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
SELECT * FROM items WHRE status=15; | SELECT * FROM items WHERE status=15; | Fix WHERE. | SQL |
values.forEach(function(y) {{ console.log(y); }}) | values.forEach((y) => {{ console.log(y); }}) | Arrow functions are cleaner. | JavaScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
'result' + 25 | 'result' + 25.to_s | Convert int. | Ruby |
<note name='data'/> | <note name="data"/> | Double quotes. | XML |
else
print('test') | else:
print('test') | Colon after else. | Python |
if (count = 18) {{}} | if (count == 18) {{}} | Use ==. | Java |
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 |
name: test
title: hello, | name: test
title: hello | Remove comma. | YAML |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
if temp = 59 | if temp == 59 | Use ==. | MATLAB |
{{'title':44, 'age' 79}} | {{'title':44, 'age':79}} | Colon missing. | Python |
let y = 41; | let y = 41; | Correct. | JavaScript |
let x: number = 'message'; | let x: string = 'message'; | Fix type. | TypeScript |
<entry><age>world</age><desc>90</desc></entry | <entry><age>world</age><desc>90</desc></entry> | Add closing >. | XML |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.