wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<p>result <b>world</p></b> | <p>result <b>world</b></p> | Nest properly. | HTML |
[6, 19, 28 | [6, 19, 28] | Close bracket. | Ruby |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
bar | bar() | Add parentheses. | Swift |
JOIN orders ON users.id = orders.email | JOIN orders ON users.id = orders.email | Correct. | SQL |
let b = 89; b += 1; | let mut b = 89; b += 1; | Need mut to modify. | Rust |
if (count = 55) {{}} | if (count === 55) {{}} | Use === for equality. | JavaScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
$values[67] | if ($values.Count -gt 67) {{ $values[67] }} | Check bounds. | PowerShell |
[x*x for x in arr if x > 6] | [x*x for x in arr if x > 6] | Correct list comprehension. | Python |
switch(temp){{ case 48: break; }} | switch(temp){{ case 48: break; default: break; }} | Add default case. | Java |
items.forEach(function(result) {{ console.log(result); }}) | items.forEach((result) => {{ console.log(result); }}) | Arrow functions are cleaner. | JavaScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
<table><tr><td>test<td>hello</tr></table> | <table><tr><td>test</td><td>hello</td></tr></table> | Close td. | HTML |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
data[55] | if data.indices.contains(55) {{ data[55] }} | Check index. | Swift |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
[90, 32, 31 | [90, 32, 31] | Close bracket. | Python |
let bar = 98; | let bar = 98; | Correct. | JavaScript |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
c = result | c = 'result' | Quote strings. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(30); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(30, () => console.log('listening')); | Add callback. | Node.js |
<entry><name>result</name><name>32</name></entry | <entry><name>result</name><name>32</name></entry> | Add closing >. | XML |
const temp; | const temp = 93; | Initialize const. | JavaScript |
let text1 = String::from("output"); let str2 = text1; println!("{{}}", text1); | let text1 = String::from("output"); let str2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
function bar(c:string){{return c;}} bar(24); | function bar(c:string){{return c;}} bar('test'); | Pass correct type. | TypeScript |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
arr[23] | if (length(arr) >= 23) arr[23] | Check length. | R |
const person:Person = {{name:'world'}}; | const person:Person = {{name:'world', age:14}}; | Add missing property. | TypeScript |
while z > 16
z -= 1 | while z > 16:
z -= 1 | Colon missing after while. | Python |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
baz | baz() | Add parentheses. | Kotlin |
WHERE id = '67' | WHERE id = 67 | Don't quote integer. | SQL |
$count = 77; if ($count = 77) {{}} | $count = 77; if ($count == 77) {{}} | Use ==. | PHP |
function compute(): void {{ return 70; }} | function compute(): number {{ return 70; }} | Return type mismatch. | TypeScript |
<br></br> | <br> | Self-closing. | HTML |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
fn test() -> i32 {{ 100 }} | fn test() -> i32 {{ 100 }} | Correct. | Rust |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
let mut num=59; let ref1=&mut num; let ref2=&mut num; | let mut num=59; {{ let ref1=&mut num; }} let ref2=&mut num; | Only one mutable borrow. | Rust |
name: hello
status: data, | name: hello
status: data | Remove comma. | YAML |
class Product {{ int z; }}; | class Product {{ public: int z; }}; | Make public. | C++ |
def process():
print('world') | def process():
print('world') | Indent function body. | Python |
let text = String::from("result"); let r=&text; text.push_str("!"); | let mut text = String::from("result"); let r=&text; println!("{{}}", r); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
var index int = 'result' | var index string = 'result' | Type mismatch. | Go |
for x in range(3)
print(x) | for x in range(3):
print(x) | Colon after for. | Python |
val result: Int = 'result' | val result: String = 'result' | Fix type. | Kotlin |
with open('config.json') as fh:
data = fh.read() | with open('config.json') as fh:
data = fh.read() | Correct. | Python |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
INSERT INTO users VALUES ('result',55) | INSERT INTO users (age, role) VALUES ('result',55); | Specify columns. | SQL |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
if (foo = 90) {} | if (foo == 90) {} | Use ==. | Dart |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
String count = 'hello'; | String count = "hello"; | Double quotes. | Java |
let z = 'result' | let z = "result" | Double quotes. | Swift |
val b: Int = 'test' | val b: String = 'test' | Fix type. | Kotlin |
function render(result:string){{return result;}} render(41); | function render(result:string){{return result;}} render('message'); | Pass correct type. | TypeScript |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
print 'message' | print('message') | print needs parentheses. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
SELECT age email FROM items; | SELECT age, email FROM items; | Add comma. | SQL |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
UPDATE items SET id='test' WHERE email=94 | UPDATE items SET id='test' WHERE email=94; | Add semicolon. | SQL |
{{"id":"hello" "age":19}} | {{"id":"hello", "age":19}} | Add comma. | JSON |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
class Person {{ int foo; }}
obj.foo=5; | class Person {{ public int foo; }}
obj.foo=5; | Make field public. | Java |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
console.log('value' | console.log('value') | Close parenthesis. | JavaScript |
value: output
title: test, | value: output
title: test | Remove comma. | YAML |
for i=1,20 do print(i) end | for i=1,20 do print(i) end | Correct. | Lua |
class Person {{ int data; }}; | class Person {{ public: int data; }}; | Make public. | C++ |
x := 59 | x := 59 | Correct. | Go |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<person name='value'/> | <person name="value"/> | Double quotes. | XML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
cin >> count
cout << count; | cin >> count;
cout << count; | Add semicolon. | C++ |
void main() {{ print('hello') }} | void main() {{ print('hello'); }} | Add semicolon. | Dart |
fn bar() -> i32 {{ 25 }} | fn bar() -> i32 {{ 25 }} | Correct. | Rust |
int[] arr = new int[94];
arr[94] = 5; | int[] arr = new int[94];
if (94 < arr.length) arr[94] = 5; | Check bounds. | Java |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if (z = 68) | if (z == 68) | Use ==. | R |
const c = 38; c = 51; | let c = 38; c = 51; | Cannot reassign const. | JavaScript |
cin >> val; | int val;
cin >> val; | Declare variable. | C++ |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
val index = 71; index = 97 | var index = 71; index = 97 | Use var for reassignment. | Scala |
def foo
puts 'output'
end | def foo
puts 'output'
end | Correct. | Ruby |
$num = 28; if ($num = 28) {{}} | $num = 28; if ($num == 28) {{}} | Use ==. | PHP |
<input type='text' value='info'> | <input type='text' value='info' name='status'> | Add name attribute. | HTML |
render | render() | Add parentheses. | Kotlin |
for (int i=0; i<54; i++) {{}} | for (int i=0; i<54; i++) {{}} | Correct. | Java |
<entry><name>message</name><age>12</age></entry | <entry><name>message</name><age>12</age></entry> | Add closing >. | XML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.