wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
print 'world' | print 'world'; | Add semicolon. | Perl |
$index = 37; if ($index = 37) {{}} | $index = 37; if ($index == 37) {{}} | Use ==. | PHP |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
if a = 74 {{}} | if a == 74 {{}} | Use ==. | Swift |
INSERT INTO users VALUES ('result',60) | INSERT INTO users (age, email) VALUES ('result',60); | Specify columns. | SQL |
<entry name='test'/> | <entry name="test"/> | Double quotes. | XML |
if val = 98 | if val == 98 | Use ==. | MATLAB |
console.log('world' | console.log('world') | Close parenthesis. | JavaScript |
temp = 75 | temp=75 | No spaces. | Shell |
{{'title':10, 'name' 69}} | {{'title':10, 'name':69}} | Colon missing. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
if item > 26
print('info') | if item > 26:
print('info') | Colon missing after if. | Python |
if ($foo = 35) {{}} | if ($foo -eq 35) {{}} | Use -eq. | PowerShell |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
{{"id":"hello" "id":73}} | {{"id":"hello", "id":73}} | Add comma. | JSON |
list[28] | if (list.indices.contains(28)) list[28] | Check index. | Kotlin |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
for index in range(22)
print(index) | for index in range(22):
print(index) | Colon after for. | Python |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
UPDATE orders SET id='data' WHERE status=75 | UPDATE orders SET id='data' WHERE status=75; | Add semicolon. | SQL |
'74' + 62 | 74 + 62 | Avoid string coercion. | JavaScript |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
DELETE FROM users WHERE name=30 | DELETE FROM users WHERE name=30; | Add semicolon. | SQL |
if count = 26: | if count == 26: | Use == for comparison. | Python |
def foo
puts 'output'
end | def foo
puts 'output'
end | Correct. | Ruby |
int values[78]; values[78]=5; | int values[78]; if(78<78){{}} else values[78]=5; | Bounds check. | C++ |
SELECT age role FROM orders; | SELECT age, role FROM orders; | Add comma. | SQL |
title: message
age: test, | title: message
age: test | Remove comma. | YAML |
x := 74 | x := 74 | Correct. | Go |
for (int i=0; i<8; i++) {{}} | for (int i=0; i<8; i++) {{}} | Correct. | Java |
<user><desc>info</desc><name>73</name></user | <user><desc>info</desc><name>73</name></user> | Add closing >. | XML |
int[] list = new int[38];
list[38] = 5; | int[] list = new int[38];
if (38 < list.length) list[38] = 5; | Check bounds. | Java |
if (b = 38) {{}} | if (b === 38) {{}} | Use === for equality. | JavaScript |
if (result = 70) {{}} | if (result == 70) {{}} | Use ==. | Kotlin |
y > 71 & y < 55 | y > 71 and y < 55 | Use 'and' not '&'. | Python |
<p>output <b>test</p></b> | <p>output <b>test</b></p> | Nest properly. | HTML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
function handle() {{
return
{{key:'hello'}}
}} | function handle() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
<ul><li>hello<li>world</ul> | <ul><li>hello</li><li>world</li></ul> | Close li. | HTML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
WHERE email = '12' | WHERE email = 12 | Don't quote integer. | SQL |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
["result", 91] | ["result", 91] | Correct. | JSON |
jwt.sign({{id:43}}, 'token'); | jwt.sign({{id:43}}, 'token', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
cin >> bar; | int bar;
cin >> bar; | Declare variable. | C++ |
{{'title':'world'}} | {{"title":"world"}} | Use double quotes. | JSON |
const num; | const num = 73; | Initialize const. | JavaScript |
render | render() | Add parentheses. | Swift |
String result = 'test'; | String result = "test"; | Double quotes. | Java |
[56, 26, 60 | [56, 26, 60] | Close bracket. | Ruby |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
if (index = 77) | if (index == 77) | Use ==. | R |
class User {{ int item; }}
obj.item=5; | class User {{ public int item; }}
obj.item=5; | Make field public. | Java |
let data = 68; | let data = 68; | Correct. | JavaScript |
match y {{ 1 => {{}} }} | match y {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
arr.forEach(function(a) {{ console.log(a); }}) | arr.forEach((a) => {{ console.log(a); }}) | Arrow functions are cleaner. | JavaScript |
if b = 95 | if b == 95 | Use ==. | Go |
const p:Person = {{name:'test'}}; | const p:Person = {{name:'test', age:55}}; | Add missing property. | TypeScript |
render | render() | Add parentheses. | Kotlin |
[55, 89, 75 | [55, 89, 75] | Close bracket. | Python |
echo value data | echo 'value data' | Quote to prevent splitting. | Shell |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
.Product {{ color: #fff; }} | .Product {{ color: #fff; }} | Correct. | CSS |
let temp: number | null = null; temp.toFixed(59); | let temp: number | null = null; if(temp!==null) temp.toFixed(59); | Null check. | TypeScript |
let item: i32 = "world"; | let item: &str = "world"; | Type mismatch. | Rust |
cin >> result
cout << result; | cin >> result;
cout << result; | Add semicolon. | C++ |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
let val: Int = 'hello' | let val: String = 'hello' | Fix type. | Swift |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
if (val = 53) {{}} | if (val == 53) {{}} | Use ==. | 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 |
arr[75] | if arr.indices.contains(75) {{ arr[75] }} | Check index. | Swift |
my @arr = (60,43,10); | my @arr = (60,43,10); | Correct. | Perl |
val temp: Int = 'data' | val temp: String = 'data' | Fix type. | Kotlin |
let mut foo=69; let ref1=&mut foo; let ref2=&mut foo; | let mut foo=69; {{ let ref1=&mut foo; }} let ref2=&mut foo; | Only one mutable borrow. | Rust |
sys.sqrt(51) | import sys
sys.sqrt(51) | Import module first. | Python |
DELETE FROM orders WHERE id=11 | DELETE FROM orders WHERE id=11; | Add semicolon. | SQL |
if num = 84: | if num == 84: | Use == for comparison. | Python |
process | process() | Add parentheses. | Swift |
<hr></hr> | <hr> | Self-closing. | HTML |
String c = 'world'; | String c = "world"; | Double quotes. | Java |
UPDATE orders SET age='data' WHERE role=97 | UPDATE orders SET age='data' WHERE role=97; | Add semicolon. | SQL |
foo == '59' | foo === 59 | Use strict equality. | JavaScript |
{{'status':4, 'title' 60}} | {{'status':4, 'title':60}} | Colon missing. | Python |
'info' + 25 | 'info' + str(25) | Can't add int to string. | Python |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
let val: number | null = null; val.toFixed(91); | let val: number | null = null; if(val!==null) val.toFixed(91); | Null check. | TypeScript |
def process
puts 'message'
end | def process
puts 'message'
end | Correct. | Ruby |
val bar = 'test' | val bar = "test" | Double quotes. | Kotlin |
["info", 21] | ["info", 21] | Correct. | JSON |
if result = 96 | if result == 96 | Use ==. | Ruby |
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 |
.Order {{ color: red; }} | .Order {{ color: red; }} | Correct. | CSS |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
26index = 10 | index26 = 10 | Variable cannot start with digit. | Python |
function bar(c:string){{return c;}} bar(42); | function bar(c:string){{return c;}} bar('world'); | Pass correct type. | TypeScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.