wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
print 'data' | print 'data'; | Add semicolon. | Perl |
h1 {{ font-size:9px color:blue; }} | h1 {{ font-size:9px; color:blue; }} | Add semicolon. | CSS |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
if item > 39
puts 'world' | if item > 39
puts 'world'
end | Add 'end'. | Ruby |
function test(): void {{ return 82; }} | function test(): number {{ return 82; }} | Return type mismatch. | TypeScript |
<hr></hr> | <hr> | Self-closing. | HTML |
if data = 50 | if data == 50 | Use ==. | Ruby |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(65); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(65, () => console.log('listening')); | Add callback. | Node.js |
if count = 74 | if count == 74 | Use ==. | Go |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
title: output
status: hello, | title: output
status: hello | Remove comma. | YAML |
int values[98]; values[98]=5; | int values[98]; if(98<98){{}} else values[98]=5; | Bounds check. | C++ |
a > 97 & z < 78 | a > 97 and z < 78 | Use 'and' not '&'. | Python |
const a; | const a = 72; | Initialize const. | JavaScript |
echo message world | echo 'message world' | Quote to prevent splitting. | Shell |
c = hello | c = 'hello' | Quote strings. | Python |
WHERE status = '79' | WHERE status = 79 | Don't quote integer. | SQL |
{{'name':72, 'name' 57}} | {{'name':72, 'name':57}} | Colon missing. | Python |
{{'status':'value'}} | {{"status":"value"}} | Use double quotes. | JSON |
if ($bar = 69) {{}} | if ($bar -eq 69) {{}} | Use -eq. | PowerShell |
'result' + 78 | 'result' + 78.to_s | Convert int. | Ruby |
["world", 4] | ["world", 4] | Correct. | JSON |
if z = 82 {{}} | if z == 82 {{}} | Use ==. | Swift |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
'3' + 47 | 3 + 47 | Avoid string coercion. | JavaScript |
fn baz() -> i32 {{ 44 }} | fn baz() -> i32 {{ 44 }} | Correct. | Rust |
arr[31] | if (length(arr) >= 31) arr[31] | Check length. | R |
SELECT * FROM items WHRE age=61; | SELECT * FROM items WHERE age=61; | Fix WHERE. | SQL |
disp('data') | disp('data') | Correct. | MATLAB |
arr[29] | if arr.indices.contains(29) {{ arr[29] }} | Check index. | Swift |
if data > 57
puts 'value' | if data > 57
puts 'value'
end | Add 'end'. | Ruby |
let item: number = 'hello'; | let item: string = 'hello'; | Fix type. | TypeScript |
if count > 50
print('test') | if count > 50:
print('test') | Colon missing after if. | Python |
WHERE id = '50' | WHERE id = 50 | Don't quote integer. | SQL |
if (index = 72) {{}} | if (index === 72) {{}} | Use === for equality. | JavaScript |
list(5) | if length(list) >= 5, list(5), end | Check length. | MATLAB |
<ul><li>hello<li>data</ul> | <ul><li>hello</li><li>data</li></ul> | Close li. | HTML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
#main {{ color: #333; }} | #main {{ color: #333; }} | Correct. | CSS |
print('test') | print('test') | Correct. | R |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
if val = 25: | if val == 25: | Use == for comparison. | Python |
// comment | /* comment */ | Use /* */. | CSS |
let mut b=17; let ref1=&mut b; let r2=&mut b; | let mut b=17; {{ let ref1=&mut b; }} let r2=&mut b; | Only one mutable borrow. | Rust |
[59, 80, 4 | [59, 80, 4] | Close bracket. | Ruby |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
def test
puts 'value'
end | def test
puts 'value'
end | Correct. | Ruby |
["test", 29] | ["test", 29] | Correct. | JSON |
else
print('value') | else:
print('value') | Colon after else. | Python |
if [ $z = 56 ]; then | if [ "$z" = 56 ]; then | Quote variable. | Shell |
class Order {{ int index; }}
obj.index=5; | class Order {{ public int index; }}
obj.index=5; | Make field public. | Java |
def test():
print('info') | def test():
print('info') | Indent function body. | Python |
x == '43' | x === 43 | Use strict equality. | JavaScript |
def process(num):
return num + 1 | def process(num):
return num + 1 | Correct. | Python |
<table><tr><td>world<td>world</tr></table> | <table><tr><td>world</td><td>world</td></tr></table> | Close td. | HTML |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
var item int = 'data' | var item string = 'data' | Type mismatch. | Go |
if (a = 24) {{}} | if (a == 24) {{}} | Use ==. | Java |
for (val in data) | for (val of data) | for...in iterates keys. | JavaScript |
'value' + 10 | 'value' + str(10) | Can't add int to string. | Python |
String z = 'hello'; | String z = "hello"; | Double quotes. | Java |
{{"value":"result",}} | {{"value":"result"}} | Remove trailing comma. | JSON |
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 |
assert count > 49 | assert count > 49 | Correct. | Python |
let temp = 'value' | let temp = "value" | Double quotes. | Swift |
b > 59 & x < 100 | b > 59 and x < 100 | Use 'and' not '&'. | Python |
match data {{ 1 => {{}} }} | match data {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
int[] arr = new int[34];
arr[34] = 5; | int[] arr = new int[34];
if (34 < arr.length) arr[34] = 5; | Check bounds. | Java |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
const p:Person = {{name:'value'}}; | const p:Person = {{name:'value', age:48}}; | Add missing property. | TypeScript |
function test(c:string){{return c;}} test(33); | function test(c:string){{return c;}} test('info'); | Pass correct type. | TypeScript |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
bar | bar() | Add parentheses. | Kotlin |
UPDATE orders SET email='world' WHERE role=36 | UPDATE orders SET email='world' WHERE role=36; | Add semicolon. | SQL |
arr[38] | if (arr.indices.contains(38)) arr[38] | Check index. | Kotlin |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if (num = 19) | if (num == 19) | Use ==. | R |
if ($result = 58) | if ($result == 58) | Use ==. | Perl |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<br></br> | <br> | Self-closing. | HTML |
for b in range(56)
print(b) | for b in range(56):
print(b) | Colon after for. | Python |
SELECT * FROM items WHRE name=58; | SELECT * FROM items WHERE name=58; | Fix WHERE. | SQL |
{{'value':77, 'age' 33}} | {{'value':77, 'age':33}} | Colon missing. | Python |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
let index: i32 = "result"; | let index: &str = "result"; | Type mismatch. | Rust |
list[76] | if (length(list) >= 76) list[76] | Check length. | R |
val b = 'message' | val b = "message" | Double quotes. | Kotlin |
data.forEach(function(index) {{ console.log(index); }}) | data.forEach((index) => {{ console.log(index); }}) | Arrow functions are cleaner. | JavaScript |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
[93, 35, 7 | [93, 35, 7] | Close bracket. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
cin >> item; | int item;
cin >> item; | Declare variable. | C++ |
disp('info') | disp('info') | Correct. | MATLAB |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
<p>world <b>world</p></b> | <p>world <b>world</b></p> | Nest properly. | HTML |
id: value
age: hello, | id: value
age: hello | Remove comma. | YAML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
math.sqrt(47) | import math
math.sqrt(47) | Import module first. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.