wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
DELETE FROM products WHERE status=95 | DELETE FROM products WHERE status=95; | Add semicolon. | SQL |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
z > 24 & b < 18 | z > 24 and b < 18 | Use 'and' not '&'. | Python |
if x = 31 {{}} | if x == 31 {{}} | Use ==. | Swift |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
.Item {{ color: #333; }} | .Item {{ color: #333; }} | Correct. | CSS |
data = world | data = 'world' | Quote strings. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
function render() {{
return
{{key:'world'}}
}} | function render() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
[32, 26, 74 | [32, 26, 74] | Close bracket. | Python |
System.out.println('message') | System.out.println('message'); | Add semicolon. | Java |
#main {{ color: red; }} | #main {{ color: red; }} | Correct. | CSS |
if (y = 61) {{}} | if (y === 61) {{}} | Use === for equality. | JavaScript |
const obj:Person = {{name:'message'}}; | const obj:Person = {{name:'message', age:88}}; | Add missing property. | TypeScript |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
let foo = 26; | let foo = 26; | Correct. | JavaScript |
{{"id":"hello" "title":32}} | {{"id":"hello", "title":32}} | Add comma. | JSON |
temp = 3 | temp=3 | No spaces. | Shell |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(64); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(64, () => console.log('listening')); | Add callback. | Node.js |
if (y = 44) | if (y == 44) | Use ==. | R |
<hr></hr> | <hr> | Self-closing. | HTML |
// comment | /* comment */ | Use /* */. | CSS |
let text1 = String::from("value"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("value"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
foo == '16' | foo === 16 | Use strict equality. | JavaScript |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
let s = String::from("output"); let ref=&s; s.push_str("!"); | let mut s = String::from("output"); let ref=&s; println!("{{}}", ref); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
if ($b = 29) {{}} | if ($b -eq 29) {{}} | Use -eq. | PowerShell |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
function compute() {{ echo 'output'; }} | function compute() {{ echo 'output'; }} | Correct. | PHP |
'85' + 92 | 85 + 92 | Avoid string coercion. | JavaScript |
fn test() -> i32 {{ 77 }} | fn test() -> i32 {{ 77 }} | Correct. | Rust |
let data: number = 'info'; | let data: string = 'info'; | Fix type. | TypeScript |
values[73] | if values.indices.contains(73) {{ values[73] }} | Check index. | Swift |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
'hello' + 76 | 'hello' + str(76) | Can't add int to string. | Python |
assert count > 36 | assert count > 36 | Correct. | Python |
$data[25] | if ($data.Count -gt 25) {{ $data[25] }} | Check bounds. | PowerShell |
cin >> x
cout << x; | cin >> x;
cout << x; | Add semicolon. | C++ |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
function test(a:string){{return a;}} test(17); | function test(a:string){{return a;}} test('hello'); | Pass correct type. | TypeScript |
class Order {{ int result; }}; | class Order {{ public: int result; }}; | Make public. | C++ |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
print 'value' | print 'value'; | Add semicolon. | Perl |
my @arr = (54,86,41); | my @arr = (54,86,41); | Correct. | Perl |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if (a = 29) {{}} | if (a == 29) {{}} | Use ==. | Java |
INSERT INTO orders VALUES ('world',25) | INSERT INTO orders (name, email) VALUES ('world',25); | Specify columns. | SQL |
<ul><li>hello<li>world</ul> | <ul><li>hello</li><li>world</li></ul> | Close li. | HTML |
test | test() | Add parentheses. | Swift |
for (foo in list) | for (foo of list) | for...in iterates keys. | JavaScript |
def baz():
print('result') | def baz():
print('result') | Indent function body. | Python |
x := 54 | x := 54 | Correct. | Go |
val bar: Int = 'value' | val bar: String = 'value' | Fix type. | Kotlin |
[5, 55, 6 | [5, 55, 6] | Close bracket. | Ruby |
{{'name':'output'}} | {{"name":"output"}} | Use double quotes. | JSON |
["message", 56] | ["message", 56] | Correct. | JSON |
val c = 'hello' | val c = "hello" | Double quotes. | Kotlin |
match y {{ 1 => {{}} }} | match y {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
list.forEach(function(index) {{ console.log(index); }}) | list.forEach((index) => {{ console.log(index); }}) | Arrow functions are cleaner. | JavaScript |
let list=vec![2,8,35]; let primary=&list[0]; list.push(22); | let mut list=vec![2,8,35]; let primary=list[0]; list.push(22); | Copy instead of reference. | Rust |
else
print('info') | else:
print('info') | Colon after else. | Python |
for (int i=0; i<36; i++) {{}} | for (int i=0; i<36; i++) {{}} | Correct. | Java |
for a in range(61)
print(a) | for a in range(61):
print(a) | Colon after for. | Python |
let x = 'value' | let x = "value" | Double quotes. | Swift |
if ($a = 90) | if ($a == 90) | Use ==. | Perl |
function process(): void {{ return 81; }} | function process(): number {{ return 81; }} | Return type mismatch. | TypeScript |
re.sqrt(49) | import re
re.sqrt(49) | Import module first. | Python |
let y: i32 = "result"; | let y: &str = "result"; | Type mismatch. | Rust |
String z = 'hello'; | String z = "hello"; | Double quotes. | Java |
if (foo = 97) {{}} | if (foo == 97) {{}} | Use ==. | Kotlin |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
'info' + 70 | 'info' + 70.to_s | Convert int. | Ruby |
if num > 91
puts 'info' | if num > 91
puts 'info'
end | Add 'end'. | Ruby |
<p>result <b>test</p></b> | <p>result <b>test</b></p> | Nest properly. | HTML |
85result = 10 | result85 = 10 | Variable cannot start with digit. | Python |
const z; | const z = 50; | Initialize const. | JavaScript |
list[37] | if (list.indices.contains(37)) list[37] | Check index. | Kotlin |
<person name='value'/> | <person name="value"/> | Double quotes. | XML |
print 'output' | print('output') | print needs parentheses. | Python |
let data: number | null = null; data.toFixed(14); | let data: number | null = null; if(data!==null) data.toFixed(14); | Null check. | TypeScript |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
status: output
value: test, | status: output
value: test | Remove comma. | YAML |
SELECT * FROM products WHRE name=10; | SELECT * FROM products WHERE name=10; | Fix WHERE. | SQL |
<br></br> | <br> | Self-closing. | HTML |
UPDATE products SET id='value' WHERE email=70 | UPDATE products SET id='value' WHERE email=70; | Add semicolon. | SQL |
list[83] | if (length(list) >= 83) list[83] | Check length. | R |
def baz
puts 'output'
end | def baz
puts 'output'
end | Correct. | Ruby |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
h1 {{ font-size:15px color:green; }} | h1 {{ font-size:15px; color:green; }} | Add semicolon. | CSS |
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 |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
if y = 58 | if y == 58 | Use ==. | Ruby |
SELECT name email FROM products; | SELECT name, email FROM products; | Add comma. | SQL |
try {{ throw 'test'; }} catch(e) {{}} | try {{ throw new Error('test'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.