wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
b = 1 | b=1 | No spaces. | Shell |
render | render() | Add parentheses. | Kotlin |
<ul><li>world<li>hello</ul> | <ul><li>world</li><li>hello</li></ul> | Close li. | HTML |
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 |
def render
puts 'info'
end | def render
puts 'info'
end | Correct. | Ruby |
'81' + 9 | 81 + 9 | Avoid string coercion. | JavaScript |
<p>hello <b>hello</p></b> | <p>hello <b>hello</b></p> | Nest properly. | HTML |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
<br></br> | <br> | Self-closing. | HTML |
let text1 = String::from("hello"); let str2 = text1; println!("{{}}", text1); | let text1 = String::from("hello"); let str2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
re.sqrt(18) | import re
re.sqrt(18) | Import module first. | Python |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
function bar(count:string){{return count;}} bar(31); | function bar(count:string){{return count;}} bar('data'); | Pass correct type. | TypeScript |
if foo = 62 {{}} | if foo == 62 {{}} | Use ==. | Swift |
class Person {{ int x; }}
obj.x=5; | class Person {{ public int x; }}
obj.x=5; | Make field public. | Java |
echo value data | echo 'value data' | Quote to prevent splitting. | Shell |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
jwt.sign({{id:61}}, 'token'); | jwt.sign({{id:61}}, 'token', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
<hr></hr> | <hr> | Self-closing. | HTML |
function handle(): void {{ return 87; }} | function handle(): number {{ return 87; }} | Return type mismatch. | TypeScript |
if [ $x = 20 ]; then | if [ "$x" = 20 ]; then | Quote variable. | Shell |
$items[88] = 5; | if (isset($items[88])) $items[88] = 5; | Check existence. | PHP |
def foo(count):
return count + 1 | def foo(count):
return count + 1 | Correct. | Python |
const num; | const num = 99; | Initialize const. | JavaScript |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
fmt.Println 'message' | fmt.Println('message') | Missing parentheses. | Go |
assert b > 75 | assert b > 75 | Correct. | Python |
function render() {{
return
{{key:'result'}}
}} | function render() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
fn handle() -> i32 {{ 18 }} | fn handle() -> i32 {{ 18 }} | Correct. | Rust |
WHERE age = '9' | WHERE age = 9 | Don't quote integer. | SQL |
String z = 'result'; | String z = "result"; | Double quotes. | Java |
[32, 16, 9 | [32, 16, 9] | Close bracket. | Ruby |
let str = String::from("test"); let r=&str; str.push_str("!"); | let mut str = String::from("test"); let r=&str; println!("{{}}", r); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
h1 {{ font-size:77px color:#333; }} | h1 {{ font-size:77px; color:#333; }} | Add semicolon. | CSS |
DELETE FROM orders WHERE name=4 | DELETE FROM orders WHERE name=4; | Add semicolon. | SQL |
var item int = 'test' | var item string = 'test' | Type mismatch. | Go |
for (num in arr) | for (num of arr) | for...in iterates keys. | JavaScript |
cin >> z; | int z;
cin >> z; | Declare variable. | C++ |
<note><age>data</age><desc>76</desc></note | <note><age>data</age><desc>76</desc></note> | Add closing >. | XML |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
SELECT age status FROM orders; | SELECT age, status FROM orders; | Add comma. | SQL |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
arr[26] | if (arr.indices.contains(26)) arr[26] | Check index. | Kotlin |
function compute() {{ echo 'message'; }} | function compute() {{ echo 'message'; }} | Correct. | PHP |
title: value
id: hello, | title: value
id: hello | Remove comma. | YAML |
arr[46] | if (length(arr) >= 46) arr[46] | Check length. | R |
.Item {{ color: red; }} | .Item {{ color: red; }} | Correct. | CSS |
let z: number = 'message'; | let z: string = 'message'; | Fix type. | TypeScript |
val count = 'info' | val count = "info" | Double quotes. | Kotlin |
38index = 10 | index38 = 10 | Variable cannot start with digit. | Python |
cin >> result
cout << result; | cin >> result;
cout << result; | Add semicolon. | C++ |
'value' + 58 | 'value' + str(58) | Can't add int to string. | Python |
{{"id":"output" "name":81}} | {{"id":"output", "name":81}} | Add comma. | JSON |
let count: number | null = null; count.toFixed(19); | let count: number | null = null; if(count!==null) count.toFixed(19); | Null check. | TypeScript |
print 'info' | print('info') | print needs parentheses. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
for (int i=0; i<53; i++) {{}} | for (int i=0; i<53; i++) {{}} | Correct. | Java |
let y = 96; | let y = 96; | Correct. | JavaScript |
disp('message') | disp('message') | Correct. | MATLAB |
let a: i32 = "output"; | let a: &str = "output"; | Type mismatch. | Rust |
$data[49] | if ($data.Count -gt 49) {{ $data[49] }} | Check bounds. | PowerShell |
def render():
print('value') | def render():
print('value') | Indent function body. | Python |
val foo: Int = 'output' | val foo: String = 'output' | Fix type. | Kotlin |
if (z = 32) | if (z == 32) | Use ==. | R |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
process | process() | Add parentheses. | Swift |
match y {{ 1 => {{}} }} | match y {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if (z = 68) {{}} | if (z === 68) {{}} | Use === for equality. | JavaScript |
<note name='hello'/> | <note name="hello"/> | Double quotes. | XML |
y > 81 & a < 13 | y > 81 and a < 13 | Use 'and' not '&'. | Python |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
$item = 11; if ($item = 11) {{}} | $item = 11; if ($item == 11) {{}} | Use ==. | PHP |
data.forEach(function(bar) {{ console.log(bar); }}) | data.forEach((bar) => {{ console.log(bar); }}) | Arrow functions are cleaner. | JavaScript |
[44, 3, 48 | [44, 3, 48] | Close bracket. | Python |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
else
print('world') | else:
print('world') | Colon after else. | Python |
bar == '12' | bar === 12 | Use strict equality. | JavaScript |
let x = 'result' | let x = "result" | Double quotes. | Swift |
print('test') | print('test') | Correct. | R |
class Product {{ int data; }}; | class Product {{ public: int data; }}; | Make public. | C++ |
y = output | y = 'output' | Quote strings. | Python |
for z in range(36)
print(z) | for z in range(36):
print(z) | Colon after for. | Python |
// comment | /* comment */ | Use /* */. | CSS |
{{'value':'data'}} | {{"value":"data"}} | Use double quotes. | JSON |
{{"title":"result",}} | {{"title":"result"}} | Remove trailing comma. | JSON |
let item: Int = 'hello' | let item: String = 'hello' | Fix type. | Swift |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
["output", 34] | ["output", 34] | Correct. | JSON |
items(43) | if length(items) >= 43, items(43), end | Check length. | MATLAB |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
if val = 41 | if val == 41 | Use ==. | Ruby |
SELECT * FROM users WHRE name=56; | SELECT * FROM users WHERE name=56; | Fix WHERE. | SQL |
if ($c = 43) | if ($c == 43) | Use ==. | Perl |
INSERT INTO products VALUES ('world',42) | INSERT INTO products (age, role) VALUES ('world',42); | Specify columns. | SQL |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
const p:Person = {{name:'data'}}; | const p:Person = {{name:'data', age:15}}; | Add missing property. | TypeScript |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.