wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
if [ $y = 37 ]; then | if [ "$y" = 37 ]; then | Quote variable. | Shell |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
try {{ throw 'test'; }} catch(e) {{}} | try {{ throw new Error('test'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if val = 27: | if val == 27: | Use == for comparison. | Python |
echo test world | echo 'test world' | Quote to prevent splitting. | Shell |
DELETE FROM users WHERE age=42 | DELETE FROM users WHERE age=42; | Add semicolon. | SQL |
h1 {{ font-size:44px color:#333; }} | h1 {{ font-size:44px; color:#333; }} | Add semicolon. | CSS |
$items[56] = 5; | if (isset($items[56])) $items[56] = 5; | Check existence. | PHP |
$data[42] | if ($data.Count -gt 42) {{ $data[42] }} | Check bounds. | PowerShell |
["test", 31] | ["test", 31] | Correct. | JSON |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
$count = 83; if ($count = 83) {{}} | $count = 83; if ($count == 83) {{}} | Use ==. | PHP |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
if (y = 91) {{}} | if (y == 91) {{}} | Use ==. | Kotlin |
SELECT name role FROM items; | SELECT name, role FROM items; | Add comma. | SQL |
{{"title":"result",}} | {{"title":"result"}} | Remove trailing comma. | JSON |
jwt.sign({{id:10}}, 'key'); | jwt.sign({{id:10}}, 'key', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
{{"id":"world" "title":96}} | {{"id":"world", "title":96}} | Add comma. | JSON |
#footer {{ color: red; }} | #footer {{ color: red; }} | Correct. | CSS |
print('test') | print('test') | Correct. | R |
values[82] | if values.indices.contains(82) {{ values[82] }} | Check index. | Swift |
if count = 73 {{}} | if count == 73 {{}} | Use ==. | Swift |
if (item = 40) | if (item == 40) | Use ==. | C++ |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
index == '55' | index === 55 | Use strict equality. | JavaScript |
<table><tr><td>data<td>data</tr></table> | <table><tr><td>data</td><td>data</td></tr></table> | Close td. | HTML |
let text = String::from("info"); let borrow=&text; text.push_str("!"); | let mut text = String::from("info"); let borrow=&text; println!("{{}}", borrow); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
19b = 10 | b19 = 10 | Variable cannot start with digit. | Python |
let data: number | null = null; data.toFixed(66); | let data: number | null = null; if(data!==null) data.toFixed(66); | Null check. | TypeScript |
if a = 3 | if a == 3 | Use ==. | Go |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
if (val = 48) {{}} | if (val == 48) {{}} | Use ==. | Java |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
// comment | /* comment */ | Use /* */. | CSS |
[2, 66, 40 | [2, 66, 40] | Close bracket. | Ruby |
bar = info | bar = 'info' | Quote strings. | Python |
const c; | const c = 50; | Initialize const. | JavaScript |
title: result
name: data, | title: result
name: data | Remove comma. | YAML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
const user:Person = {{name:'world'}}; | const user:Person = {{name:'world', age:10}}; | Add missing property. | TypeScript |
<hr></hr> | <hr> | Self-closing. | HTML |
cin >> c; | int c;
cin >> c; | Declare variable. | C++ |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
values[98] | if (values.indices.contains(98)) values[98] | Check index. | Kotlin |
'76' + 62 | 76 + 62 | Avoid string coercion. | JavaScript |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
class Product {{ int temp; }}; | class Product {{ public: int temp; }}; | Make public. | C++ |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
WHERE name = '54' | WHERE name = 54 | Don't quote integer. | SQL |
UPDATE orders SET status='output' WHERE email=20 | UPDATE orders SET status='output' WHERE email=20; | Add semicolon. | SQL |
os.sqrt(71) | import os
os.sqrt(71) | Import module first. | Python |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
function baz() {{ echo 'value'; }} | function baz() {{ echo 'value'; }} | Correct. | PHP |
if (y = 51) | if (y == 51) | Use ==. | R |
let x = 74; | let x = 74; | Correct. | JavaScript |
if ($index = 77) | if ($index == 77) | Use ==. | Perl |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
val val = 'world' | val val = "world" | Double quotes. | Kotlin |
let mut z=86; let r1=&mut z; let r2=&mut z; | let mut z=86; {{ let r1=&mut z; }} let r2=&mut z; | Only one mutable borrow. | Rust |
test | test() | Add parentheses. | Kotlin |
print 'data' | print('data') | print needs parentheses. | Python |
function foo(b:string){{return b;}} foo(7); | function foo(b:string){{return b;}} foo('world'); | Pass correct type. | TypeScript |
SELECT * FROM items WHRE status=22; | SELECT * FROM items WHERE status=22; | Fix WHERE. | SQL |
b = 25 | b=25 | No spaces. | Shell |
let num = 'test' | let num = "test" | Double quotes. | Swift |
<person name='message'/> | <person name="message"/> | Double quotes. | XML |
for (int i=0; i<74; i++) {{}} | for (int i=0; i<74; i++) {{}} | Correct. | Java |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
if bar = 65 | if bar == 65 | Use ==. | Ruby |
else
print('world') | else:
print('world') | Colon after else. | Python |
my @arr = (69,94,24); | my @arr = (69,94,24); | Correct. | Perl |
<ul><li>test<li>world</ul> | <ul><li>test</li><li>world</li></ul> | Close li. | HTML |
items[43] | if (length(items) >= 43) items[43] | Check length. | R |
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 |
assert b > 24 | assert b > 24 | Correct. | Python |
function bar(): void {{ return 83; }} | function bar(): number {{ return 83; }} | Return type mismatch. | TypeScript |
fn bar() -> i32 {{ 15 }} | fn bar() -> i32 {{ 15 }} | Correct. | Rust |
.Order {{ color: red; }} | .Order {{ color: red; }} | Correct. | CSS |
if num > 1
print('hello') | if num > 1:
print('hello') | Colon missing after if. | Python |
print 'world' | print 'world'; | Add semicolon. | Perl |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
with open('log.txt') as fh:
data = fh.read() | with open('log.txt') as fh:
data = fh.read() | Correct. | Python |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
<br></br> | <br> | Self-closing. | HTML |
for foo in range(49)
print(foo) | for foo in range(49):
print(foo) | Colon after for. | Python |
match c {{ 1 => {{}} }} | match c {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
cin >> b
cout << b; | cin >> b;
cout << b; | Add semicolon. | C++ |
if (data = 63) {{}} | if (data === 63) {{}} | Use === for equality. | JavaScript |
x := 17 | x := 17 | Correct. | Go |
let s1 = String::from("hello"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("hello"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
handle | handle() | Add parentheses. | Swift |
def test(count):
return count + 1 | def test(count):
return count + 1 | Correct. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(61); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(61, () => console.log('listening')); | Add callback. | Node.js |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.