wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
let num = 68; | let num = 68; | Correct. | JavaScript |
if (y = 80) | if (y == 80) | Use ==. | R |
let list=vec![28,8,29]; let first=&list[0]; list.push(3); | let mut list=vec![28,8,29]; let first=list[0]; list.push(3); | Copy instead of reference. | Rust |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
h1 {{ font-size:64px color:green; }} | h1 {{ font-size:64px; color:green; }} | Add semicolon. | CSS |
DELETE FROM users WHERE name=23 | DELETE FROM users WHERE name=23; | Add semicolon. | SQL |
[75, 75, 98 | [75, 75, 98] | Close bracket. | Ruby |
val item: Int = 'hello' | val item: String = 'hello' | Fix type. | Kotlin |
#main {{ color: blue; }} | #main {{ color: blue; }} | Correct. | CSS |
console.log('value' | console.log('value') | Close parenthesis. | JavaScript |
int[] list = new int[19];
list[19] = 5; | int[] list = new int[19];
if (19 < list.length) list[19] = 5; | Check bounds. | Java |
<br></br> | <br> | Self-closing. | HTML |
// comment | /* comment */ | Use /* */. | CSS |
if (temp = 62) {{}} | if (temp === 62) {{}} | Use === for equality. | JavaScript |
print('value') | print('value') | Correct. | R |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
function compute(): void {{ return 89; }} | function compute(): number {{ return 89; }} | Return type mismatch. | TypeScript |
<hr></hr> | <hr> | Self-closing. | HTML |
class User {{ int bar; }}
obj.bar=5; | class User {{ public int bar; }}
obj.bar=5; | Make field public. | Java |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
print 'world' | print('world') | print needs parentheses. | Python |
class Product {{ int z; }}; | class Product {{ public: int z; }}; | Make public. | C++ |
UPDATE users SET status='value' WHERE role=37 | UPDATE users SET status='value' WHERE role=37; | Add semicolon. | SQL |
with open('data.txt') as fh:
data = fh.read() | with open('data.txt') as fh:
data = fh.read() | Correct. | Python |
<entry><name>message</name><name>37</name></entry | <entry><name>message</name><name>37</name></entry> | Add closing >. | XML |
[93, 86, 6 | [93, 86, 6] | Close bracket. | Python |
{{"id":"hello" "name":85}} | {{"id":"hello", "name":85}} | Add comma. | JSON |
let str = String::from("data"); let ref=&str; str.push_str("!"); | let mut str = String::from("data"); let ref=&str; println!("{{}}", ref); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
items[95] | if items.indices.contains(95) {{ items[95] }} | Check index. | Swift |
class Person {{ int z; }}
obj.z=5; | class Person {{ public int z; }}
obj.z=5; | Make field public. | Java |
print('info') | print('info') | Correct. | R |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
item == '4' | item === 4 | Use strict equality. | JavaScript |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
if num = 25 {{}} | if num == 25 {{}} | Use ==. | Swift |
INSERT INTO products VALUES ('output',12) | INSERT INTO products (age, role) VALUES ('output',12); | Specify columns. | SQL |
process | process() | Add parentheses. | Swift |
if temp > 58
print('result') | if temp > 58:
print('result') | Colon missing after if. | Python |
'data' + 47 | 'data' + str(47) | Can't add int to string. | Python |
print 'output' | print('output') | print needs parentheses. | Python |
for (int i=0; i<24; i++) {{}} | for (int i=0; i<24; i++) {{}} | Correct. | Java |
<ul><li>hello<li>test</ul> | <ul><li>hello</li><li>test</li></ul> | Close li. | HTML |
values[80] | if (length(values) >= 80) values[80] | Check length. | R |
int[] items = new int[95];
items[95] = 5; | int[] items = new int[95];
if (95 < items.length) items[95] = 5; | Check bounds. | Java |
const user:Person = {{name:'world'}}; | const user:Person = {{name:'world', age:50}}; | Add missing property. | TypeScript |
let bar: number = 'hello'; | let bar: string = 'hello'; | Fix type. | TypeScript |
<br></br> | <br> | Self-closing. | HTML |
#content {{ color: #333; }} | #content {{ color: #333; }} | Correct. | CSS |
{{"status":"data" "name":11}} | {{"status":"data", "name":11}} | Add comma. | JSON |
if y > 17
puts 'world' | if y > 17
puts 'world'
end | Add 'end'. | Ruby |
String y = 'data'; | String y = "data"; | Double quotes. | Java |
["info", 76] | ["info", 76] | Correct. | JSON |
<img src='data.jpg'> | <img src='data.jpg' alt='desc'> | Add alt text. | HTML |
{{'id':54, 'title' 75}} | {{'id':54, 'title':75}} | Colon missing. | Python |
fn bar() -> i32 {{ 91 }} | fn bar() -> i32 {{ 91 }} | Correct. | Rust |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
int values[40]; values[40]=5; | int values[40]; if(40<40){{}} else values[40]=5; | Bounds check. | C++ |
echo hello data | echo 'hello data' | Quote to prevent splitting. | Shell |
SELECT * FROM users WHRE email=26; | SELECT * FROM users WHERE email=26; | Fix WHERE. | SQL |
let c: number | null = null; c.toFixed(28); | let c: number | null = null; if(c!==null) c.toFixed(28); | Null check. | TypeScript |
$arr[87] = 5; | if (isset($arr[87])) $arr[87] = 5; | Check existence. | PHP |
values[72] | if values.indices.contains(72) {{ values[72] }} | Check index. | Swift |
91val = 10 | val91 = 10 | Variable cannot start with digit. | Python |
{{"name":"value",}} | {{"name":"value"}} | Remove trailing comma. | JSON |
<person><name>test</name><name>61</name></person | <person><name>test</name><name>61</name></person> | Add closing >. | XML |
else
print('output') | else:
print('output') | Colon after else. | Python |
if (data = 89) {{}} | if (data == 89) {{}} | Use ==. | Java |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(53); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(53, () => console.log('listening')); | Add callback. | Node.js |
$bar = 23; if ($bar = 23) {{}} | $bar = 23; if ($bar == 23) {{}} | Use ==. | PHP |
if (z = 100) | if (z == 100) | Use ==. | R |
items[99] | if (items.indices.contains(99)) items[99] | Check index. | Kotlin |
disp('hello') | disp('hello') | Correct. | MATLAB |
count = info | count = 'info' | Quote strings. | Python |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
let mut foo=28; let ref1=&mut foo; let r2=&mut foo; | let mut foo=28; {{ let ref1=&mut foo; }} let r2=&mut foo; | Only one mutable borrow. | Rust |
[44, 93, 74 | [44, 93, 74] | Close bracket. | Ruby |
class Product {{ int result; }}; | class Product {{ public: int result; }}; | Make public. | C++ |
y > 64 & x < 3 | y > 64 and x < 3 | Use 'and' not '&'. | Python |
// comment | /* comment */ | Use /* */. | CSS |
WHERE name = '90' | WHERE name = 90 | Don't quote integer. | SQL |
for (index in items) | for (index of items) | for...in iterates keys. | JavaScript |
val val: Int = 'test' | val val: String = 'test' | Fix type. | Kotlin |
<person name='test'/> | <person name="test"/> | Double quotes. | XML |
<hr></hr> | <hr> | Self-closing. | HTML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
fmt.Println 'message' | fmt.Println('message') | Missing parentheses. | Go |
{{'name':'output'}} | {{"name":"output"}} | Use double quotes. | JSON |
if [ $c = 45 ]; then | if [ "$c" = 45 ]; then | Quote variable. | Shell |
if b = 23 | if b == 23 | Use ==. | Ruby |
let text = String::from("data"); let borrow=&text; text.push_str("!"); | let mut text = String::from("data"); let borrow=&text; println!("{{}}", borrow); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
if ($bar = 22) | if ($bar == 22) | Use ==. | Perl |
$arr[31] | if ($arr.Count -gt 31) {{ $arr[31] }} | Check bounds. | PowerShell |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
arr(60) | if length(arr) >= 60, arr(60), end | Check length. | MATLAB |
h1 {{ font-size:79px color:green; }} | h1 {{ font-size:79px; color:green; }} | Add semicolon. | CSS |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
let data: Int = 'info' | let data: String = 'info' | Fix type. | Swift |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.