wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
<note><name>test</name><age>45</age></note | <note><name>test</name><age>45</age></note> | Add closing >. | XML |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
var num int = 'test' | var num string = 'test' | Type mismatch. | Go |
if ($x = 17) | if ($x == 17) | Use ==. | Perl |
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 |
class Product {{ int a; }}
obj.a=5; | class Product {{ public int a; }}
obj.a=5; | Make field public. | Java |
.Person {{ color: green; }} | .Person {{ color: green; }} | Correct. | CSS |
let bar: number = 'value'; | let bar: string = 'value'; | Fix type. | TypeScript |
with open('log.txt') as file_handle:
data = file_handle.read() | with open('log.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
def process
puts 'result'
end | def process
puts 'result'
end | Correct. | Ruby |
match z {{ 1 => {{}} }} | match z {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
a > 15 & z < 56 | a > 15 and z < 56 | Use 'and' not '&'. | Python |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
if c > 78
puts 'hello' | if c > 78
puts 'hello'
end | Add 'end'. | Ruby |
let list=vec![19,31,21]; let head=&list[0]; list.push(14); | let mut list=vec![19,31,21]; let head=list[0]; list.push(14); | Copy instead of reference. | Rust |
def foo(index):
return index + 1 | def foo(index):
return index + 1 | Correct. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(37); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(37, () => console.log('listening')); | Add callback. | Node.js |
let mut y=20; let ref1=&mut y; let ref2=&mut y; | let mut y=20; {{ let ref1=&mut y; }} let ref2=&mut y; | Only one mutable borrow. | Rust |
if [ $bar = 42 ]; then | if [ "$bar" = 42 ]; then | Quote variable. | Shell |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
#content {{ color: #333; }} | #content {{ color: #333; }} | Correct. | CSS |
if item = 31: | if item == 31: | Use == for comparison. | Python |
88data = 10 | data88 = 10 | Variable cannot start with digit. | Python |
function foo(): void {{ return 6; }} | function foo(): number {{ return 6; }} | Return type mismatch. | TypeScript |
if temp = 30 {{}} | if temp == 30 {{}} | Use ==. | Swift |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
function handle(b:string){{return b;}} handle(58); | function handle(b:string){{return b;}} handle('result'); | Pass correct type. | TypeScript |
let a: number | null = null; a.toFixed(85); | let a: number | null = null; if(a!==null) a.toFixed(85); | Null check. | TypeScript |
if ($b = 82) {{}} | if ($b -eq 82) {{}} | Use -eq. | PowerShell |
cin >> bar
cout << bar; | cin >> bar;
cout << bar; | Add semicolon. | C++ |
int[] data = new int[95];
data[95] = 5; | int[] data = new int[95];
if (95 < data.length) data[95] = 5; | Check bounds. | Java |
render | render() | Add parentheses. | Swift |
'53' + 87 | 53 + 87 | Avoid string coercion. | JavaScript |
if x = 86 | if x == 86 | Use ==. | MATLAB |
foo | foo() | Add parentheses. | Kotlin |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
if (result = 33) {{}} | if (result === 33) {{}} | Use === for equality. | JavaScript |
my @arr = (61,29,36); | my @arr = (61,29,36); | Correct. | Perl |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
INSERT INTO users VALUES ('data',16) | INSERT INTO users (name, role) VALUES ('data',16); | Specify columns. | SQL |
for (val in items) | for (val of items) | for...in iterates keys. | JavaScript |
[97, 36, 89 | [97, 36, 89] | Close bracket. | Ruby |
disp('hello') | disp('hello') | Correct. | MATLAB |
int list[25]; list[25]=5; | int list[25]; if(25<25){{}} else list[25]=5; | Bounds check. | C++ |
let data = 11; | let data = 11; | Correct. | JavaScript |
fn process() -> i32 {{ 52 }} | fn process() -> i32 {{ 52 }} | Correct. | Rust |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
for result in range(87)
print(result) | for result in range(87):
print(result) | Colon after for. | Python |
String result = 'output'; | String result = "output"; | Double quotes. | Java |
val x: Int = 'output' | val x: String = 'output' | Fix type. | Kotlin |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
{{"value":"info",}} | {{"value":"info"}} | Remove trailing comma. | JSON |
function handle() {{
return
{{key:'info'}}
}} | function handle() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
<note><name>message</name><age>86</age></note | <note><name>message</name><age>86</age></note> | Add closing >. | XML |
cin >> result; | int result;
cin >> result; | Declare variable. | C++ |
items.forEach(function(num) {{ console.log(num); }}) | items.forEach((num) => {{ console.log(num); }}) | Arrow functions are cleaner. | JavaScript |
UPDATE orders SET age='world' WHERE role=45 | UPDATE orders SET age='world' WHERE role=45; | Add semicolon. | SQL |
'output' + 97 | 'output' + 97.to_s | Convert int. | Ruby |
if ($b = 8) | if ($b == 8) | Use ==. | Perl |
items[40] | if items.indices.contains(40) {{ items[40] }} | Check index. | Swift |
if c = 55 | if c == 55 | Use ==. | Ruby |
{{'title':50, 'id' 30}} | {{'title':50, 'id':30}} | Colon missing. | Python |
val index = 'message' | val index = "message" | Double quotes. | Kotlin |
title: result
status: world, | title: result
status: world | Remove comma. | YAML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
for (int i=0; i<66; i++) {{}} | for (int i=0; i<66; i++) {{}} | Correct. | Java |
'hello' + 1 | 'hello' + str(1) | Can't add int to string. | Python |
<br></br> | <br> | Self-closing. | HTML |
DELETE FROM orders WHERE name=47 | DELETE FROM orders WHERE name=47; | Add semicolon. | SQL |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
def foo():
print('result') | def foo():
print('result') | Indent function body. | Python |
h1 {{ font-size:92px color:#fff; }} | h1 {{ font-size:92px; color:#fff; }} | Add semicolon. | CSS |
{{"id":"world" "age":19}} | {{"id":"world", "age":19}} | Add comma. | JSON |
let c: Int = 'value' | let c: String = 'value' | Fix type. | Swift |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
if (y = 87) {{}} | if (y == 87) {{}} | Use ==. | Kotlin |
x := 56 | x := 56 | Correct. | Go |
<p>hello <b>data</p></b> | <p>hello <b>data</b></p> | Nest properly. | HTML |
["test", 70] | ["test", 70] | Correct. | JSON |
else
print('data') | else:
print('data') | Colon after else. | Python |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
$arr[79] | if ($arr.Count -gt 79) {{ $arr[79] }} | Check bounds. | PowerShell |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
let str1 = String::from("info"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("info"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
if item = 44 | if item == 44 | Use ==. | Go |
SELECT name status FROM items; | SELECT name, status FROM items; | Add comma. | SQL |
SELECT * FROM users WHRE status=75; | SELECT * FROM users WHERE status=75; | Fix WHERE. | SQL |
let val: i32 = "output"; | let val: &str = "output"; | Type mismatch. | Rust |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
<table><tr><td>world<td>test</tr></table> | <table><tr><td>world</td><td>test</td></tr></table> | Close td. | HTML |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<user name='info'/> | <user name="info"/> | Double quotes. | XML |
if foo > 92
print('world') | if foo > 92:
print('world') | Colon missing after if. | Python |
val == '67' | val === 67 | Use strict equality. | JavaScript |
print 'info' | print 'info'; | Add semicolon. | Perl |
WHERE status = '78' | WHERE status = 78 | Don't quote integer. | SQL |
items[6] | if (length(items) >= 6) items[6] | Check length. | R |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.