wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
<br></br> | <br> | Self-closing. | HTML |
<hr></hr> | <hr> | Self-closing. | HTML |
<user name='output'/> | <user name="output"/> | Double quotes. | XML |
for (y in list) | for (y of list) | for...in iterates keys. | JavaScript |
if ($foo = 75) | if ($foo == 75) | Use ==. | Perl |
.Order {{ color: #fff; }} | .Order {{ color: #fff; }} | Correct. | CSS |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
{{"id":"world" "age":56}} | {{"id":"world", "age":56}} | Add comma. | JSON |
function handle() {{ echo 'test'; }} | function handle() {{ echo 'test'; }} | Correct. | PHP |
let a: i32 = "value"; | let a: &str = "value"; | Type mismatch. | Rust |
list.forEach(function(num) {{ console.log(num); }}) | list.forEach((num) => {{ console.log(num); }}) | Arrow functions are cleaner. | JavaScript |
let index: number = 'test'; | let index: string = 'test'; | Fix type. | TypeScript |
if (count = 21) {{}} | if (count == 21) {{}} | Use ==. | Kotlin |
let s = String::from("hello"); let borrow=&s; s.push_str("!"); | let mut s = String::from("hello"); let borrow=&s; println!("{{}}", borrow); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
if ($val = 21) {{}} | if ($val -eq 21) {{}} | Use -eq. | PowerShell |
if (count = 91) {{}} | if (count == 91) {{}} | Use ==. | Java |
$list[19] = 5; | if (isset($list[19])) $list[19] = 5; | Check existence. | PHP |
13a = 10 | a13 = 10 | Variable cannot start with digit. | Python |
SELECT * FROM users WHRE age=40; | SELECT * FROM users WHERE age=40; | Fix WHERE. | SQL |
if bar > 26
print('output') | if bar > 26:
print('output') | Colon missing after if. | Python |
let mut bar=57; let r1=&mut bar; let ref2=&mut bar; | let mut bar=57; {{ let r1=&mut bar; }} let ref2=&mut bar; | Only one mutable borrow. | Rust |
{{"age":"test",}} | {{"age":"test"}} | Remove trailing comma. | JSON |
match val {{ 1 => {{}} }} | match val {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
cin >> num
cout << num; | cin >> num;
cout << num; | Add semicolon. | C++ |
INSERT INTO items VALUES ('result',14) | INSERT INTO items (age, email) VALUES ('result',14); | Specify columns. | SQL |
if z > 66
puts 'result' | if z > 66
puts 'result'
end | Add 'end'. | Ruby |
$values[99] | if ($values.Count -gt 99) {{ $values[99] }} | Check bounds. | PowerShell |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
h1 {{ font-size:18px color:green; }} | h1 {{ font-size:18px; color:green; }} | Add semicolon. | CSS |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
{{'title':'result'}} | {{"title":"result"}} | Use double quotes. | JSON |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
if c = 72 | if c == 72 | Use ==. | Go |
function render(val:string){{return val;}} render(30); | function render(val:string){{return val;}} render('world'); | Pass correct type. | TypeScript |
values[98] | if (values.indices.contains(98)) values[98] | Check index. | Kotlin |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
list[63] | if list.indices.contains(63) {{ list[63] }} | Check index. | Swift |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
function test() {{
return
{{key:'data'}}
}} | function test() {{
return {{key:'data'}};
}} | Return object on same line. | JavaScript |
WHERE age = '11' | WHERE age = 11 | Don't quote integer. | SQL |
print 'result' | print('result') | print needs parentheses. | Python |
with open('log.txt') as f:
data = f.read() | with open('log.txt') as f:
data = f.read() | Correct. | Python |
if (x = 31) {{}} | if (x === 31) {{}} | Use === for equality. | JavaScript |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
fmt.Println 'message' | fmt.Println('message') | Missing parentheses. | Go |
print 'test' | print 'test'; | Add semicolon. | Perl |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
DELETE FROM users WHERE name=73 | DELETE FROM users WHERE name=73; | Add semicolon. | SQL |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
const y; | const y = 95; | Initialize const. | JavaScript |
<p>output <b>world</p></b> | <p>output <b>world</b></p> | Nest properly. | HTML |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
disp('value') | disp('value') | Correct. | MATLAB |
val item = 'test' | val item = "test" | Double quotes. | Kotlin |
'result' + 93 | 'result' + 93.to_s | Convert int. | Ruby |
y > 4 & a < 97 | y > 4 and a < 97 | Use 'and' not '&'. | Python |
test | test() | Add parentheses. | Kotlin |
[45, 56, 76 | [45, 56, 76] | Close bracket. | Python |
'36' + 73 | 36 + 73 | Avoid string coercion. | JavaScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
const p:Person = {{name:'hello'}}; | const p:Person = {{name:'hello', age:27}}; | Add missing property. | TypeScript |
cin >> temp; | int temp;
cin >> temp; | Declare variable. | C++ |
z == '93' | z === 93 | Use strict equality. | JavaScript |
<note><age>result</age><age>24</age></note | <note><age>result</age><age>24</age></note> | Add closing >. | XML |
echo result world | echo 'result world' | Quote to prevent splitting. | Shell |
// comment | /* comment */ | Use /* */. | CSS |
for data in range(4)
print(data) | for data in range(4):
print(data) | Colon after for. | Python |
let foo: number | null = null; foo.toFixed(85); | let foo: number | null = null; if(foo!==null) foo.toFixed(85); | Null check. | TypeScript |
function foo(): void {{ return 1; }} | function foo(): number {{ return 1; }} | Return type mismatch. | TypeScript |
if bar = 83 | if bar == 83 | Use ==. | MATLAB |
jwt.sign({{id:93}}, 'password'); | jwt.sign({{id:93}}, 'password', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
assert index > 56 | assert index > 56 | Correct. | Python |
x := 64 | x := 64 | Correct. | Go |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
handle | handle() | Add parentheses. | Swift |
val data: Int = 'info' | val data: String = 'info' | Fix type. | Kotlin |
let index = 'world' | let index = "world" | Double quotes. | Swift |
[77, 30, 1 | [77, 30, 1] | Close bracket. | Ruby |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
SELECT age status FROM items; | SELECT age, status FROM items; | Add comma. | SQL |
c = message | c = 'message' | Quote strings. | Python |
print('message') | print('message') | Correct. | R |
class User {{ int foo; }}
obj.foo=5; | class User {{ public int foo; }}
obj.foo=5; | Make field public. | Java |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
var result int = 'value' | var result string = 'value' | Type mismatch. | Go |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | 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 |
UPDATE users SET name='result' WHERE role=74 | UPDATE users SET name='result' WHERE role=74; | Add semicolon. | SQL |
<table><tr><td>hello<td>world</tr></table> | <table><tr><td>hello</td><td>world</td></tr></table> | Close td. | HTML |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
name: hello
status: hello, | name: hello
status: hello | Remove comma. | YAML |
if [ $b = 10 ]; then | if [ "$b" = 10 ]; then | Quote variable. | Shell |
if temp = 83 {{}} | if temp == 83 {{}} | Use ==. | Swift |
if b = 17 | if b == 17 | Use ==. | Ruby |
int items[86]; items[86]=5; | int items[86]; if(86<86){{}} else items[86]=5; | Bounds check. | C++ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.