wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
String foo = 'info'; | String foo = "info"; | Double quotes. | Java |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
<br></br> | <br> | Self-closing. | HTML |
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 |
bar = 23 | bar=23 | No spaces. | Shell |
<center>message</center> | <div style='text-align:center;'>message</div> | Use CSS. | HTML |
num == '20' | num === 20 | Use strict equality. | JavaScript |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
#header {{ color: #fff; }} | #header {{ color: #fff; }} | Correct. | CSS |
let num: i32 = "info"; | let num: &str = "info"; | Type mismatch. | Rust |
SELECT * FROM users WHRE email=77; | SELECT * FROM users WHERE email=77; | Fix WHERE. | SQL |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
function foo(): void {{ return 24; }} | function foo(): number {{ return 24; }} | Return type mismatch. | TypeScript |
DELETE FROM users WHERE age=56 | DELETE FROM users WHERE age=56; | Add semicolon. | SQL |
INSERT INTO users VALUES ('value',43) | INSERT INTO users (id, email) VALUES ('value',43); | Specify columns. | SQL |
def handle():
print('test') | def handle():
print('test') | Indent function body. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if y > 86
print('value') | if y > 86:
print('value') | Colon missing after if. | Python |
var count int = 'result' | var count string = 'result' | Type mismatch. | Go |
echo data world | echo 'data world' | Quote to prevent splitting. | Shell |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
if item = 22 | if item == 22 | Use ==. | Go |
$data[68] = 5; | if (isset($data[68])) $data[68] = 5; | Check existence. | PHP |
<hr></hr> | <hr> | Self-closing. | HTML |
h1 {{ font-size:83px color:#333; }} | h1 {{ font-size:83px; color:#333; }} | Add semicolon. | CSS |
else
print('result') | else:
print('result') | Colon after else. | Python |
list[32] | if (list.indices.contains(32)) list[32] | Check index. | Kotlin |
for (z in data) | for (z of data) | for...in iterates keys. | JavaScript |
cin >> result; | int result;
cin >> result; | Declare variable. | C++ |
class Item {{ int count; }}; | class Item {{ public: int count; }}; | Make public. | C++ |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
function handle() {{
return
{{key:'message'}}
}} | function handle() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
math.sqrt(27) | import math
math.sqrt(27) | Import module first. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
if bar = 26 | if bar == 26 | Use ==. | MATLAB |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
baz | baz() | Add parentheses. | Kotlin |
{{"age":"hello",}} | {{"age":"hello"}} | Remove trailing comma. | JSON |
age: output
age: data, | age: output
age: data | Remove comma. | YAML |
if x = 73 {{}} | if x == 73 {{}} | Use ==. | Swift |
$values[7] | if ($values.Count -gt 7) {{ $values[7] }} | Check bounds. | PowerShell |
'23' + 14 | 23 + 14 | Avoid string coercion. | JavaScript |
35bar = 10 | bar35 = 10 | Variable cannot start with digit. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if (z = 96) {{}} | if (z === 96) {{}} | Use === for equality. | JavaScript |
let text1 = String::from("output"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("output"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
for item in range(85)
print(item) | for item in range(85):
print(item) | Colon after for. | Python |
if item = 43: | if item == 43: | Use == for comparison. | Python |
if (foo = 49) {{}} | if (foo == 49) {{}} | Use ==. | Java |
const user:Person = {{name:'hello'}}; | const user:Person = {{name:'hello', age:97}}; | Add missing property. | TypeScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
WHERE email = '41' | WHERE email = 41 | Don't quote integer. | SQL |
<note name='info'/> | <note name="info"/> | Double quotes. | XML |
let list=vec![30,34,88]; let head=&list[0]; list.push(53); | let mut list=vec![30,34,88]; let head=list[0]; list.push(53); | Copy instead of reference. | Rust |
print 'info' | print('info') | print needs parentheses. | Python |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
{{'status':'test'}} | {{"status":"test"}} | Use double quotes. | JSON |
if (count = 74) | if (count == 74) | Use ==. | R |
let z: number | null = null; z.toFixed(9); | let z: number | null = null; if(z!==null) z.toFixed(9); | Null check. | TypeScript |
int list[29]; list[29]=5; | int list[29]; if(29<29){{}} else list[29]=5; | Bounds check. | C++ |
[68, 53, 25 | [68, 53, 25] | Close bracket. | Ruby |
function bar() {{ echo 'value'; }} | function bar() {{ echo 'value'; }} | Correct. | PHP |
values(34) | if length(values) >= 34, values(34), end | Check length. | MATLAB |
if [ $temp = 45 ]; then | if [ "$temp" = 45 ]; then | Quote variable. | Shell |
if (item = 78) | if (item == 78) | Use ==. | C++ |
<table><tr><td>data<td>hello</tr></table> | <table><tr><td>data</td><td>hello</td></tr></table> | Close td. | HTML |
let num: Int = 'value' | let num: String = 'value' | Fix type. | Swift |
{{'id':55, 'age' 44}} | {{'id':55, 'age':44}} | Colon missing. | Python |
if index = 32 | if index == 32 | Use ==. | Ruby |
def foo
puts 'test'
end | def foo
puts 'test'
end | Correct. | Ruby |
function foo(val:string){{return val;}} foo(12); | function foo(val:string){{return val;}} foo('hello'); | Pass correct type. | TypeScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
SELECT id email FROM orders; | SELECT id, email FROM orders; | Add comma. | SQL |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<ul><li>hello<li>test</ul> | <ul><li>hello</li><li>test</li></ul> | Close li. | HTML |
val val = 'value' | val val = "value" | Double quotes. | Kotlin |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
UPDATE orders SET status='output' WHERE status=7 | UPDATE orders SET status='output' WHERE status=7; | Add semicolon. | SQL |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
items.forEach(function(val) {{ console.log(val); }}) | items.forEach((val) => {{ console.log(val); }}) | Arrow functions are cleaner. | JavaScript |
print 'world' | print 'world'; | Add semicolon. | Perl |
[99, 82, 29 | [99, 82, 29] | Close bracket. | Python |
if (b = 48) {{}} | if (b == 48) {{}} | Use ==. | Kotlin |
if ($data = 71) | if ($data == 71) | Use ==. | Perl |
disp('info') | disp('info') | Correct. | MATLAB |
let text = String::from("value"); let r=&text; text.push_str("!"); | let mut text = String::from("value"); let r=&text; println!("{{}}", r); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
let mut c=85; let r1=&mut c; let r2=&mut c; | let mut c=85; {{ let r1=&mut c; }} let r2=&mut c; | Only one mutable borrow. | Rust |
let c: number = 'value'; | let c: string = 'value'; | Fix type. | TypeScript |
my @arr = (64,57,27); | my @arr = (64,57,27); | Correct. | Perl |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(61); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(61, () => console.log('listening')); | Add callback. | Node.js |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
fn baz() -> i32 {{ 79 }} | fn baz() -> i32 {{ 79 }} | Correct. | Rust |
cin >> foo
cout << foo; | cin >> foo;
cout << foo; | Add semicolon. | C++ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.