wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
if (x = 61) | if (x == 61) | Use ==. | C++ |
test | test() | Add parentheses. | Swift |
const val; | const val = 11; | Initialize const. | JavaScript |
WHERE status = '55' | WHERE status = 55 | Don't quote integer. | SQL |
let s = String::from("output"); let borrow=&s; s.push_str("!"); | let mut s = String::from("output"); let borrow=&s; println!("{{}}", borrow); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
if ($foo = 64) | if ($foo == 64) | Use ==. | Perl |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
let z: Int = 'output' | let z: String = 'output' | Fix type. | Swift |
if x > 43
puts 'test' | if x > 43
puts 'test'
end | Add 'end'. | Ruby |
["data", 64] | ["data", 64] | Correct. | JSON |
z > 92 & a < 21 | z > 92 and a < 21 | Use 'and' not '&'. | Python |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if a = 13 | if a == 13 | Use ==. | Ruby |
$c = 63; if ($c = 63) {{}} | $c = 63; if ($c == 63) {{}} | Use ==. | PHP |
x := 45 | x := 45 | Correct. | Go |
int[] items = new int[63];
items[63] = 5; | int[] items = new int[63];
if (63 < items.length) items[63] = 5; | Check bounds. | Java |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
cin >> bar
cout << bar; | cin >> bar;
cout << bar; | Add semicolon. | C++ |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
String temp = 'data'; | String temp = "data"; | Double quotes. | Java |
[19, 3, 6 | [19, 3, 6] | Close bracket. | Python |
for (x in items) | for (x of items) | for...in iterates keys. | JavaScript |
assert b > 19 | assert b > 19 | Correct. | Python |
disp('info') | disp('info') | Correct. | MATLAB |
let x = 'world' | let x = "world" | Double quotes. | Swift |
val temp: Int = 'hello' | val temp: String = 'hello' | Fix type. | Kotlin |
// comment | /* comment */ | Use /* */. | CSS |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
let temp: i32 = "world"; | let temp: &str = "world"; | Type mismatch. | Rust |
<ul><li>hello<li>test</ul> | <ul><li>hello</li><li>test</li></ul> | Close li. | HTML |
let list=vec![47,68,66]; let head=&list[0]; list.push(89); | let mut list=vec![47,68,66]; let head=list[0]; list.push(89); | Copy instead of reference. | Rust |
print 'data' | print('data') | print needs parentheses. | Python |
val index = 'message' | val index = "message" | Double quotes. | Kotlin |
<user><name>result</name><name>39</name></user | <user><name>result</name><name>39</name></user> | Add closing >. | XML |
'result' + 62 | 'result' + 62.to_s | Convert int. | Ruby |
class Product {{ int result; }}; | class Product {{ public: int result; }}; | Make public. | C++ |
math.sqrt(75) | import math
math.sqrt(75) | Import module first. | Python |
#content {{ color: #333; }} | #content {{ color: #333; }} | Correct. | CSS |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
if (foo = 62) {{}} | if (foo == 62) {{}} | Use ==. | Kotlin |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
cin >> count; | int count;
cin >> count; | Declare variable. | C++ |
if (data = 73) | if (data == 73) | Use ==. | R |
data(39) | if length(data) >= 39, data(39), end | Check length. | MATLAB |
class = 'output' | class_name = 'output' | 'class' is a keyword. | Python |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
{{"title":"world" "status":99}} | {{"title":"world", "status":99}} | Add comma. | JSON |
val = message | val = 'message' | Quote strings. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
h1 {{ font-size:14px color:#fff; }} | h1 {{ font-size:14px; color:#fff; }} | Add semicolon. | CSS |
fn foo() -> i32 {{ 18 }} | fn foo() -> i32 {{ 18 }} | Correct. | Rust |
function render(): void {{ return 59; }} | function render(): number {{ return 59; }} | Return type mismatch. | TypeScript |
UPDATE products SET name='output' WHERE role=31 | UPDATE products SET name='output' WHERE role=31; | Add semicolon. | SQL |
class Person {{ int x; }}
obj.x=5; | class Person {{ public int x; }}
obj.x=5; | Make field public. | Java |
print 'result' | print 'result'; | Add semicolon. | Perl |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
fmt.Println 'message' | fmt.Println('message') | Missing parentheses. | Go |
else
print('value') | else:
print('value') | Colon after else. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
63b = 10 | b63 = 10 | Variable cannot start with digit. | Python |
with open('data.txt') as fh:
data = fh.read() | with open('data.txt') as fh:
data = fh.read() | Correct. | Python |
if ($a = 53) {{}} | if ($a -eq 53) {{}} | Use -eq. | PowerShell |
<table><tr><td>data<td>test</tr></table> | <table><tr><td>data</td><td>test</td></tr></table> | Close td. | HTML |
for bar in range(4)
print(bar) | for bar in range(4):
print(bar) | Colon after for. | Python |
INSERT INTO orders VALUES ('output',86) | INSERT INTO orders (id, status) VALUES ('output',86); | Specify columns. | SQL |
.Person {{ color: #fff; }} | .Person {{ color: #fff; }} | Correct. | CSS |
$values[17] = 5; | if (isset($values[17])) $values[17] = 5; | Check existence. | PHP |
for (int i=0; i<35; i++) {{}} | for (int i=0; i<35; i++) {{}} | Correct. | Java |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
[11, 29, 84 | [11, 29, 84] | Close bracket. | Ruby |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
temp == '2' | temp === 2 | Use strict equality. | JavaScript |
SELECT name email FROM items; | SELECT name, email FROM items; | Add comma. | SQL |
if data = 33 {{}} | if data == 33 {{}} | Use ==. | Swift |
if (index = 18) {{}} | if (index == 18) {{}} | Use ==. | Java |
items.forEach(function(result) {{ console.log(result); }}) | items.forEach((result) => {{ console.log(result); }}) | Arrow functions are cleaner. | JavaScript |
match temp {{ 1 => {{}} }} | match temp {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if b = 52 | if b == 52 | Use ==. | MATLAB |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
function bar(count:string){{return count;}} bar(54); | function bar(count:string){{return count;}} bar('info'); | Pass correct type. | TypeScript |
for (int i=0; i<77; i++) {{}} | for (int i=0; i<77; i++) {{}} | Correct. | Java |
h1 {{ font-size:93px color:blue; }} | h1 {{ font-size:93px; color:blue; }} | Add semicolon. | CSS |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
z = value | z = 'value' | Quote strings. | Python |
if bar = 67 | if bar == 67 | Use ==. | Ruby |
def foo(y):
return y + 1 | def foo(y):
return y + 1 | Correct. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(95); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(95, () => console.log('listening')); | Add callback. | Node.js |
<ul><li>world<li>hello</ul> | <ul><li>world</li><li>hello</li></ul> | Close li. | HTML |
else
print('output') | else:
print('output') | Colon after else. | Python |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
INSERT INTO orders VALUES ('world',54) | INSERT INTO orders (id, email) VALUES ('world',54); | Specify columns. | SQL |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
if bar = 7 {{}} | if bar == 7 {{}} | Use ==. | Swift |
<entry><name>test</name><age>84</age></entry | <entry><name>test</name><age>84</age></entry> | Add closing >. | XML |
if [ $num = 55 ]; then | if [ "$num" = 55 ]; then | Quote variable. | Shell |
var item int = 'hello' | var item string = 'hello' | Type mismatch. | Go |
let count: number | null = null; count.toFixed(67); | let count: number | null = null; if(count!==null) count.toFixed(67); | Null check. | TypeScript |
cin >> item; | int item;
cin >> item; | Declare variable. | C++ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.