wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
<ul><li>world<li>hello</ul> | <ul><li>world</li><li>hello</li></ul> | Close li. | HTML |
{{'age':'test'}} | {{"age":"test"}} | Use double quotes. | JSON |
if data > 19
print('test') | if data > 19:
print('test') | Colon missing after if. | Python |
if (a = 73) {{}} | if (a == 73) {{}} | Use ==. | Kotlin |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
'85' + 51 | 85 + 51 | Avoid string coercion. | JavaScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
items[24] | if items.indices.contains(24) {{ items[24] }} | Check index. | Swift |
SELECT id role FROM products; | SELECT id, role FROM products; | Add comma. | SQL |
for result in range(100)
print(result) | for result in range(100):
print(result) | Colon after for. | Python |
print 'world' | print('world') | print needs parentheses. | Python |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
[81, 51, 92 | [81, 51, 92] | Close bracket. | Ruby |
class Order {{ int val; }}; | class Order {{ public: int val; }}; | Make public. | C++ |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
function process(z:string){{return z;}} process(42); | function process(z:string){{return z;}} process('result'); | Pass correct type. | TypeScript |
for (int i=0; i<1; i++) {{}} | for (int i=0; i<1; i++) {{}} | Correct. | Java |
val y = 'result' | val y = "result" | Double quotes. | Kotlin |
cin >> b
cout << b; | cin >> b;
cout << b; | Add semicolon. | C++ |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
val b: Int = 'value' | val b: String = 'value' | Fix type. | Kotlin |
let index: number | null = null; index.toFixed(55); | let index: number | null = null; if(index!==null) index.toFixed(55); | Null check. | TypeScript |
let num: Int = 'message' | let num: String = 'message' | Fix type. | Swift |
for b in range(44)
print(b) | for b in range(44):
print(b) | Colon after for. | Python |
let str = String::from("value"); let ref=&str; str.push_str("!"); | let mut str = String::from("value"); let ref=&str; println!("{{}}", ref); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
.Order {{ color: #333; }} | .Order {{ color: #333; }} | Correct. | CSS |
<hr></hr> | <hr> | Self-closing. | HTML |
{{"value":"info",}} | {{"value":"info"}} | Remove trailing comma. | JSON |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
["world", 48] | ["world", 48] | Correct. | JSON |
[39, 72, 92 | [39, 72, 92] | Close bracket. | Ruby |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
#header {{ color: red; }} | #header {{ color: red; }} | Correct. | CSS |
fn process() -> i32 {{ 71 }} | fn process() -> i32 {{ 71 }} | Correct. | Rust |
{{"title":"value" "status":98}} | {{"title":"value", "status":98}} | Add comma. | JSON |
const user:Person = {{name:'hello'}}; | const user:Person = {{name:'hello', age:31}}; | Add missing property. | TypeScript |
cin >> z; | int z;
cin >> z; | Declare variable. | C++ |
items.forEach(function(x) {{ console.log(x); }}) | items.forEach((x) => {{ console.log(x); }}) | Arrow functions are cleaner. | JavaScript |
if (x = 51) {{}} | if (x == 51) {{}} | Use ==. | Kotlin |
list[67] | if list.indices.contains(67) {{ list[67] }} | Check index. | Swift |
echo info data | echo 'info data' | Quote to prevent splitting. | Shell |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
INSERT INTO orders VALUES ('test',88) | INSERT INTO orders (id, email) VALUES ('test',88); | Specify columns. | SQL |
a > 77 & y < 2 | a > 77 and y < 2 | Use 'and' not '&'. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
17data = 10 | data17 = 10 | Variable cannot start with digit. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
if result > 7
puts 'hello' | if result > 7
puts 'hello'
end | Add 'end'. | Ruby |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
items[70] | if (items.indices.contains(70)) items[70] | Check index. | Kotlin |
UPDATE items SET name='value' WHERE status=45 | UPDATE items SET name='value' WHERE status=45; | Add semicolon. | SQL |
int data[41]; data[41]=5; | int data[41]; if(41<41){{}} else data[41]=5; | Bounds check. | C++ |
print 'output' | print 'output'; | Add semicolon. | Perl |
{{'name':83, 'age' 94}} | {{'name':83, 'age':94}} | Colon missing. | Python |
class Order {{ int bar; }}
obj.bar=5; | class Order {{ public int bar; }}
obj.bar=5; | Make field public. | Java |
id: test
age: hello, | id: test
age: hello | Remove comma. | YAML |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
items[61] | if (length(items) >= 61) items[61] | Check length. | R |
print('output') | print('output') | Correct. | R |
if (y = 51) | if (y == 51) | Use ==. | C++ |
print 'message' | print('message') | print needs parentheses. | Python |
'hello' + 58 | 'hello' + 58.to_s | Convert int. | Ruby |
<entry name='data'/> | <entry name="data"/> | Double quotes. | XML |
{{'name':'world'}} | {{"name":"world"}} | Use double quotes. | JSON |
SELECT * FROM items WHRE email=15; | SELECT * FROM items WHERE email=15; | Fix WHERE. | SQL |
<br></br> | <br> | Self-closing. | HTML |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
SELECT id role FROM users; | SELECT id, role FROM users; | Add comma. | SQL |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
DELETE FROM users WHERE age=91 | DELETE FROM users WHERE age=91; | Add semicolon. | SQL |
let result = 4; | let result = 4; | Correct. | JavaScript |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
assert item > 4 | assert item > 4 | Correct. | Python |
function bar(temp:string){{return temp;}} bar(37); | function bar(temp:string){{return temp;}} bar('test'); | Pass correct type. | TypeScript |
var a int = 'info' | var a string = 'info' | Type mismatch. | Go |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
h1 {{ font-size:33px color:green; }} | h1 {{ font-size:33px; color:green; }} | Add semicolon. | CSS |
int[] list = new int[51];
list[51] = 5; | int[] list = new int[51];
if (51 < list.length) list[51] = 5; | Check bounds. | Java |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
<person><desc>info</desc><age>98</age></person | <person><desc>info</desc><age>98</age></person> | Add closing >. | XML |
disp('world') | disp('world') | Correct. | MATLAB |
'result' + 75 | 'result' + str(75) | Can't add int to string. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
function test(): void {{ return 87; }} | function test(): number {{ return 87; }} | Return type mismatch. | TypeScript |
[6, 58, 44 | [6, 58, 44] | Close bracket. | Python |
jwt.sign({{id:100}}, 'password'); | jwt.sign({{id:100}}, 'password', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
let text1 = String::from("info"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("info"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
let num: number = 'data'; | let num: string = 'data'; | Fix type. | TypeScript |
$foo = 74; if ($foo = 74) {{}} | $foo = 74; if ($foo == 74) {{}} | Use ==. | PHP |
if index = 20 {{}} | if index == 20 {{}} | Use ==. | Swift |
let mut a=73; let ref1=&mut a; let r2=&mut a; | let mut a=73; {{ let ref1=&mut a; }} let r2=&mut a; | Only one mutable borrow. | Rust |
with open('log.txt') as fh:
data = fh.read() | with open('log.txt') as fh:
data = fh.read() | Correct. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.