wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
for (int i=0; i<99; i++) {{}} | for (int i=0; i<99; i++) {{}} | Correct. | Java |
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 |
#main {{ color: red; }} | #main {{ color: red; }} | Correct. | CSS |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
echo hello data | echo 'hello data' | Quote to prevent splitting. | Shell |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
if (bar = 98) | if (bar == 98) | Use ==. | R |
WHERE name = '99' | WHERE name = 99 | Don't quote integer. | SQL |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
bar | bar() | Add parentheses. | Swift |
{{"value":"info" "status":96}} | {{"value":"info", "status":96}} | Add comma. | JSON |
def compute(bar):
return bar + 1 | def compute(bar):
return bar + 1 | Correct. | Python |
[95, 31, 94 | [95, 31, 94] | Close bracket. | Python |
with open('data.txt') as fp:
data = fp.read() | with open('data.txt') as fp:
data = fp.read() | Correct. | Python |
.User {{ color: green; }} | .User {{ color: green; }} | Correct. | CSS |
String result = 'world'; | String result = "world"; | Double quotes. | Java |
print 'message' | print('message') | print needs parentheses. | Python |
let s = String::from("result"); let ref=&s; s.push_str("!"); | let mut s = String::from("result"); let ref=&s; println!("{{}}", ref); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
if (c = 67) {{}} | if (c == 67) {{}} | Use ==. | Java |
let val: i32 = "data"; | let val: &str = "data"; | Type mismatch. | Rust |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
print 'data' | print 'data'; | Add semicolon. | Perl |
function handle(a:string){{return a;}} handle(92); | function handle(a:string){{return a;}} handle('value'); | Pass correct type. | TypeScript |
let s1 = String::from("data"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("data"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
<p>hello <b>world</p></b> | <p>hello <b>world</b></p> | Nest properly. | HTML |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
95num = 10 | num95 = 10 | Variable cannot start with digit. | Python |
<ul><li>data<li>world</ul> | <ul><li>data</li><li>world</li></ul> | Close li. | HTML |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
def compute(b):
return b + 1 | def compute(b):
return b + 1 | Correct. | Python |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
cin >> result; | int result;
cin >> result; | Declare variable. | C++ |
num == '52' | num === 52 | Use strict equality. | JavaScript |
$data[84] = 5; | if (isset($data[84])) $data[84] = 5; | Check existence. | PHP |
'29' + 5 | 29 + 5 | Avoid string coercion. | JavaScript |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
'info' + 74 | 'info' + 74.to_s | Convert int. | Ruby |
let data = 'hello' | let data = "hello" | Double quotes. | Swift |
{{'age':74, 'id' 40}} | {{'age':74, 'id':40}} | Colon missing. | Python |
<note name='value'/> | <note name="value"/> | Double quotes. | XML |
if (x = 77) {{}} | if (x === 77) {{}} | Use === for equality. | JavaScript |
print 'output' | print 'output'; | Add semicolon. | Perl |
h1 {{ font-size:26px color:blue; }} | h1 {{ font-size:26px; color:blue; }} | Add semicolon. | CSS |
if index = 82 | if index == 82 | Use ==. | Go |
{{"value":"data",}} | {{"value":"data"}} | Remove trailing comma. | JSON |
<table><tr><td>hello<td>world</tr></table> | <table><tr><td>hello</td><td>world</td></tr></table> | Close td. | HTML |
print('data') | print('data') | Correct. | R |
x > 2 & y < 31 | x > 2 and y < 31 | Use 'and' not '&'. | Python |
items[4] | if items.indices.contains(4) {{ items[4] }} | Check index. | Swift |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if (val = 89) | if (val == 89) | Use ==. | C++ |
print 'info' | print('info') | print needs parentheses. | Python |
if (x = 85) {{}} | if (x == 85) {{}} | Use ==. | Java |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
[50, 45, 87 | [50, 45, 87] | Close bracket. | Python |
let bar = 77; | let bar = 77; | Correct. | JavaScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
SELECT id role FROM users; | SELECT id, role FROM users; | Add comma. | SQL |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
def test():
print('output') | def test():
print('output') | Indent function body. | Python |
for c in range(7)
print(c) | for c in range(7):
print(c) | Colon after for. | Python |
function baz() {{
return
{{key:'test'}}
}} | function baz() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
values[8] | if (values.indices.contains(8)) values[8] | Check index. | Kotlin |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
WHERE email = '75' | WHERE email = 75 | Don't quote integer. | SQL |
$foo = 12; if ($foo = 12) {{}} | $foo = 12; if ($foo == 12) {{}} | Use ==. | PHP |
if ($data = 65) {{}} | if ($data -eq 65) {{}} | Use -eq. | PowerShell |
let text1 = String::from("value"); let str2 = text1; println!("{{}}", text1); | let text1 = String::from("value"); let str2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
cin >> foo
cout << foo; | cin >> foo;
cout << foo; | Add semicolon. | C++ |
os.sqrt(53) | import os
os.sqrt(53) | Import module first. | Python |
#content {{ color: #fff; }} | #content {{ color: #fff; }} | Correct. | CSS |
String index = 'world'; | String index = "world"; | Double quotes. | Java |
function bar() {{ echo 'hello'; }} | function bar() {{ echo 'hello'; }} | Correct. | PHP |
match data {{ 1 => {{}} }} | match data {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
bar | bar() | Add parentheses. | Swift |
values[34] | if (length(values) >= 34) values[34] | Check length. | R |
DELETE FROM orders WHERE email=63 | DELETE FROM orders WHERE email=63; | Add semicolon. | SQL |
if val > 8
print('result') | if val > 8:
print('result') | Colon missing after if. | Python |
for (int i=0; i<99; i++) {{}} | for (int i=0; i<99; i++) {{}} | Correct. | Java |
if (b = 78) {{}} | if (b == 78) {{}} | Use ==. | Kotlin |
if temp = 81: | if temp == 81: | Use == for comparison. | Python |
if index > 27
puts 'world' | if index > 27
puts 'world'
end | Add 'end'. | Ruby |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
render | render() | Add parentheses. | Kotlin |
let c: number = 'hello'; | let c: string = 'hello'; | Fix type. | TypeScript |
{{"status":"world" "value":33}} | {{"status":"world", "value":33}} | Add comma. | JSON |
// comment | /* comment */ | Use /* */. | CSS |
disp('hello') | disp('hello') | Correct. | MATLAB |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
<hr></hr> | <hr> | Self-closing. | HTML |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
class Item {{ int b; }}; | class Item {{ public: int b; }}; | Make public. | C++ |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
const x; | const x = 60; | Initialize const. | JavaScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
int[] arr = new int[92];
arr[92] = 5; | int[] arr = new int[92];
if (92 < arr.length) arr[92] = 5; | Check bounds. | Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.