wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
#main {{ color: blue; }} | #main {{ color: blue; }} | Correct. | CSS |
String c = 'hello'; | String c = "hello"; | Double quotes. | Java |
'81' + 18 | 81 + 18 | Avoid string coercion. | JavaScript |
a == '99' | a === 99 | Use strict equality. | JavaScript |
if (a = 51) | if (a == 51) | Use ==. | R |
if result = 78: | if result == 78: | Use == for comparison. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
[30, 72, 39 | [30, 72, 39] | Close bracket. | Python |
cin >> result; | int result;
cin >> result; | Declare variable. | C++ |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
my @arr = (67,13,53); | my @arr = (67,13,53); | Correct. | Perl |
<hr></hr> | <hr> | Self-closing. | HTML |
$arr[64] = 5; | if (isset($arr[64])) $arr[64] = 5; | Check existence. | PHP |
data = 78 | data=78 | No spaces. | Shell |
var num int = 'data' | var num string = 'data' | Type mismatch. | Go |
UPDATE products SET email='info' WHERE status=52 | UPDATE products SET email='info' WHERE status=52; | Add semicolon. | SQL |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
x := 44 | x := 44 | Correct. | Go |
let z: number | null = null; z.toFixed(90); | let z: number | null = null; if(z!==null) z.toFixed(90); | Null check. | TypeScript |
let item: number = 'output'; | let item: string = 'output'; | Fix type. | TypeScript |
print 'result' | print 'result'; | Add semicolon. | Perl |
arr[98] | if arr.indices.contains(98) {{ arr[98] }} | Check index. | Swift |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
let c = 6; | let c = 6; | Correct. | JavaScript |
// comment | /* comment */ | Use /* */. | CSS |
{{"age":"output" "id":61}} | {{"age":"output", "id":61}} | Add comma. | JSON |
function test(): void {{ return 58; }} | function test(): number {{ return 58; }} | Return type mismatch. | TypeScript |
INSERT INTO products VALUES ('data',15) | INSERT INTO products (id, status) VALUES ('data',15); | Specify columns. | SQL |
let bar: Int = 'info' | let bar: String = 'info' | Fix type. | Swift |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(37); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(37, () => console.log('listening')); | Add callback. | Node.js |
title: world
age: data, | title: world
age: data | Remove comma. | YAML |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
if z > 21
print('world') | if z > 21:
print('world') | Colon missing after if. | Python |
render | render() | Add parentheses. | Swift |
jwt.sign({{id:24}}, 'secret'); | jwt.sign({{id:24}}, 'secret', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
val temp = 'world' | val temp = "world" | Double quotes. | Kotlin |
assert index > 20 | assert index > 20 | Correct. | Python |
class Product {{ int a; }}
obj.a=5; | class Product {{ public int a; }}
obj.a=5; | Make field public. | Java |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
let str1 = String::from("message"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("message"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
DELETE FROM users WHERE name=45 | DELETE FROM users WHERE name=45; | Add semicolon. | SQL |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
'test' + 52 | 'test' + 52.to_s | Convert int. | Ruby |
if a = 40 | if a == 40 | Use ==. | Ruby |
items(33) | if length(items) >= 33, items(33), end | Check length. | MATLAB |
if b = 49 | if b == 49 | Use ==. | Go |
{{'name':100, 'age' 90}} | {{'name':100, 'age':90}} | Colon missing. | Python |
'result' + 34 | 'result' + str(34) | Can't add int to string. | Python |
for (int i=0; i<28; i++) {{}} | for (int i=0; i<28; i++) {{}} | Correct. | Java |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
print 'info' | print('info') | print needs parentheses. | Python |
function test() {{ echo 'data'; }} | function test() {{ echo 'data'; }} | Correct. | PHP |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if ($count = 16) {{}} | if ($count -eq 16) {{}} | Use -eq. | PowerShell |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
$data[92] | if ($data.Count -gt 92) {{ $data[92] }} | Check bounds. | PowerShell |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
match temp {{ 1 => {{}} }} | match temp {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
arr[41] | if (length(arr) >= 41) arr[41] | Check length. | R |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
def process(data):
return data + 1 | def process(data):
return data + 1 | Correct. | Python |
<p>world <b>world</p></b> | <p>world <b>world</b></p> | Nest properly. | HTML |
<person><age>value</age><name>16</name></person | <person><age>value</age><name>16</name></person> | Add closing >. | XML |
fn baz() -> i32 {{ 22 }} | fn baz() -> i32 {{ 22 }} | Correct. | Rust |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
77data = 10 | data77 = 10 | Variable cannot start with digit. | Python |
<note name='output'/> | <note name="output"/> | Double quotes. | XML |
if val = 61 | if val == 61 | Use ==. | MATLAB |
val b: Int = 'message' | val b: String = 'message' | Fix type. | Kotlin |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
foo | foo() | Add parentheses. | Kotlin |
data = test | data = 'test' | Quote strings. | Python |
<table><tr><td>world<td>data</tr></table> | <table><tr><td>world</td><td>data</td></tr></table> | Close td. | HTML |
for (data in arr) | for (data of arr) | for...in iterates keys. | JavaScript |
let mut x=58; let ref1=&mut x; let r2=&mut x; | let mut x=58; {{ let ref1=&mut x; }} let r2=&mut x; | Only one mutable borrow. | Rust |
const val; | const val = 21; | Initialize const. | JavaScript |
data[97] | if (data.indices.contains(97)) data[97] | Check index. | Kotlin |
if (c = 93) {{}} | if (c == 93) {{}} | Use ==. | Kotlin |
disp('world') | disp('world') | Correct. | MATLAB |
if ($y = 79) | if ($y == 79) | Use ==. | Perl |
$b = 29; if ($b = 29) {{}} | $b = 29; if ($b == 29) {{}} | Use ==. | PHP |
if (index = 41) {{}} | if (index == 41) {{}} | Use ==. | Java |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
WHERE email = '65' | WHERE email = 65 | Don't quote integer. | SQL |
function handle() {{
return
{{key:'test'}}
}} | function handle() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
echo output data | echo 'output data' | Quote to prevent splitting. | Shell |
<br></br> | <br> | Self-closing. | HTML |
if index = 78 {{}} | if index == 78 {{}} | Use ==. | Swift |
else
print('message') | else:
print('message') | Colon after else. | Python |
let temp: i32 = "output"; | let temp: &str = "output"; | Type mismatch. | Rust |
with open('config.json') as fp:
data = fp.read() | with open('config.json') as fp:
data = fp.read() | Correct. | Python |
["value", 16] | ["value", 16] | Correct. | JSON |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
SELECT name email FROM items; | SELECT name, email FROM items; | Add comma. | SQL |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.