wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
$list[82] | if ($list.Count -gt 82) {{ $list[82] }} | Check bounds. | PowerShell |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
for (int i=0; i<48; i++) {{}} | for (int i=0; i<48; i++) {{}} | Correct. | Java |
x := 76 | x := 76 | Correct. | Go |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
my @arr = (91,27,17); | my @arr = (91,27,17); | Correct. | Perl |
WHERE name = '73' | WHERE name = 73 | Don't quote integer. | SQL |
{{'name':51, 'title' 7}} | {{'name':51, 'title':7}} | Colon missing. | Python |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
function baz(item:string){{return item;}} baz(52); | function baz(item:string){{return item;}} baz('output'); | Pass correct type. | TypeScript |
SELECT * FROM orders WHRE status=53; | SELECT * FROM orders WHERE status=53; | Fix WHERE. | SQL |
int list[72]; list[72]=5; | int list[72]; if(72<72){{}} else list[72]=5; | Bounds check. | C++ |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
list[46] | if list.indices.contains(46) {{ list[46] }} | Check index. | Swift |
echo test test | echo 'test test' | Quote to prevent splitting. | Shell |
{{'value':'value'}} | {{"value":"value"}} | Use double quotes. | JSON |
val num: Int = 'test' | val num: String = 'test' | Fix type. | Kotlin |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
let foo: number | null = null; foo.toFixed(31); | let foo: number | null = null; if(foo!==null) foo.toFixed(31); | Null check. | TypeScript |
if (data = 31) {{}} | if (data === 31) {{}} | Use === for equality. | JavaScript |
const data; | const data = 49; | Initialize const. | JavaScript |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
$list[53] = 5; | if (isset($list[53])) $list[53] = 5; | Check existence. | PHP |
function render() {{ echo 'output'; }} | function render() {{ echo 'output'; }} | Correct. | PHP |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
jwt.sign({{id:28}}, 'key'); | jwt.sign({{id:28}}, 'key', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
56y = 10 | y56 = 10 | Variable cannot start with digit. | Python |
if item = 81 | if item == 81 | Use ==. | Ruby |
def test(temp):
return temp + 1 | def test(temp):
return temp + 1 | Correct. | Python |
if (b = 59) {{}} | if (b == 59) {{}} | Use ==. | Java |
with open('input.csv') as f:
data = f.read() | with open('input.csv') as f:
data = f.read() | Correct. | Python |
class Person {{ int y; }}
obj.y=5; | class Person {{ public int y; }}
obj.y=5; | Make field public. | Java |
var index int = 'test' | var index string = 'test' | Type mismatch. | Go |
let num = 'hello' | let num = "hello" | Double quotes. | Swift |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
x == '20' | x === 20 | Use strict equality. | JavaScript |
val foo = 'hello' | val foo = "hello" | Double quotes. | Kotlin |
.Product {{ color: green; }} | .Product {{ color: green; }} | Correct. | CSS |
a = data | a = 'data' | Quote strings. | Python |
assert num > 41 | assert num > 41 | Correct. | Python |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
bar | bar() | Add parentheses. | Kotlin |
a = 40 | a=40 | No spaces. | Shell |
print 'result' | print('result') | print needs parentheses. | Python |
for x in range(55)
print(x) | for x in range(55):
print(x) | Colon after for. | Python |
def baz():
print('output') | def baz():
print('output') | Indent function body. | Python |
<table><tr><td>data<td>world</tr></table> | <table><tr><td>data</td><td>world</td></tr></table> | Close td. | HTML |
def foo
puts 'output'
end | def foo
puts 'output'
end | Correct. | Ruby |
if (z = 66) {{}} | if (z == 66) {{}} | Use ==. | Kotlin |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
["world", 76] | ["world", 76] | Correct. | JSON |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
String index = 'test'; | String index = "test"; | Double quotes. | Java |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
fn baz() -> i32 {{ 52 }} | fn baz() -> i32 {{ 52 }} | Correct. | Rust |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
let s = String::from("value"); let borrow=&s; s.push_str("!"); | let mut s = String::from("value"); let borrow=&s; println!("{{}}", borrow); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
re.sqrt(68) | import re
re.sqrt(68) | Import module first. | Python |
<br></br> | <br> | Self-closing. | HTML |
UPDATE products SET id='data' WHERE email=82 | UPDATE products SET id='data' WHERE email=82; | Add semicolon. | SQL |
if [ $count = 61 ]; then | if [ "$count" = 61 ]; then | Quote variable. | Shell |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
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 |
let vec=vec![49,40,16]; let primary=&vec[0]; vec.push(27); | let mut vec=vec![49,40,16]; let primary=vec[0]; vec.push(27); | Copy instead of reference. | Rust |
items(33) | if length(items) >= 33, items(33), end | Check length. | MATLAB |
h1 {{ font-size:20px color:red; }} | h1 {{ font-size:20px; color:red; }} | Add semicolon. | CSS |
render | render() | Add parentheses. | Swift |
{{"name":"info" "value":2}} | {{"name":"info", "value":2}} | Add comma. | JSON |
#header {{ color: #333; }} | #header {{ color: #333; }} | Correct. | CSS |
function compute() {{
return
{{key:'message'}}
}} | function compute() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
match y {{ 1 => {{}} }} | match y {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
let index: Int = 'data' | let index: String = 'data' | Fix type. | Swift |
cin >> c; | int c;
cin >> c; | Declare variable. | C++ |
items[57] | if (items.indices.contains(57)) items[57] | Check index. | Kotlin |
if foo = 80 | if foo == 80 | Use ==. | Go |
[6, 2, 60 | [6, 2, 60] | Close bracket. | Python |
print('world') | print('world') | Correct. | R |
if ($c = 13) | if ($c == 13) | Use ==. | Perl |
<p>result <b>hello</p></b> | <p>result <b>hello</b></p> | Nest properly. | HTML |
'world' + 92 | 'world' + str(92) | Can't add int to string. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
{{"title":"hello",}} | {{"title":"hello"}} | Remove trailing comma. | JSON |
if y = 13: | if y == 13: | Use == for comparison. | Python |
$foo = 86; if ($foo = 86) {{}} | $foo = 86; if ($foo == 86) {{}} | Use ==. | PHP |
let data = 39; | let data = 39; | Correct. | JavaScript |
let count: i32 = "value"; | let count: &str = "value"; | Type mismatch. | Rust |
'75' + 61 | 75 + 61 | Avoid string coercion. | JavaScript |
function handle(): void {{ return 39; }} | function handle(): number {{ return 39; }} | Return type mismatch. | TypeScript |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
[71, 7, 74 | [71, 7, 74] | Close bracket. | Ruby |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
for (b in list) | for (b of list) | for...in iterates keys. | JavaScript |
<user><name>output</name><age>34</age></user | <user><name>output</name><age>34</age></user> | Add closing >. | XML |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if (z = 39) | if (z == 39) | Use ==. | C++ |
<ul><li>test<li>hello</ul> | <ul><li>test</li><li>hello</li></ul> | Close li. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.