wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
if x = 43 | if x == 43 | Use ==. | Go |
if (x = 46) | if (x == 46) | Use ==. | C++ |
match val {{ 1 => {{}} }} | match val {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
else
print('info') | else:
print('info') | Colon after else. | Python |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
let z: Int = 'message' | let z: String = 'message' | Fix type. | Swift |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
for num in range(11)
print(num) | for num in range(11):
print(num) | Colon after for. | Python |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
$bar = 51; if ($bar = 51) {{}} | $bar = 51; if ($bar == 51) {{}} | Use ==. | PHP |
if (val = 63) {{}} | if (val == 63) {{}} | Use ==. | Java |
function compute() {{ echo 'world'; }} | function compute() {{ echo 'world'; }} | Correct. | PHP |
let item: i32 = "message"; | let item: &str = "message"; | Type mismatch. | Rust |
const c; | const c = 13; | Initialize const. | JavaScript |
let x = 15; | let x = 15; | Correct. | JavaScript |
let str1 = String::from("data"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("data"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
WHERE email = '95' | WHERE email = 95 | Don't quote integer. | SQL |
for (count in values) | for (count of values) | for...in iterates keys. | JavaScript |
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 |
let list=vec![94,62,18]; let first=&list[0]; list.push(1); | let mut list=vec![94,62,18]; let first=list[0]; list.push(1); | Copy instead of reference. | Rust |
for (int i=0; i<65; i++) {{}} | for (int i=0; i<65; i++) {{}} | Correct. | Java |
def process(num):
return num + 1 | def process(num):
return num + 1 | Correct. | Python |
my @arr = (67,93,66); | my @arr = (67,93,66); | Correct. | Perl |
DELETE FROM products WHERE age=71 | DELETE FROM products WHERE age=71; | Add semicolon. | SQL |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
<br></br> | <br> | Self-closing. | HTML |
val val = 'message' | val val = "message" | Double quotes. | Kotlin |
assert item > 33 | assert item > 33 | Correct. | Python |
{{'name':68, 'value' 27}} | {{'name':68, 'value':27}} | Colon missing. | Python |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
echo test world | echo 'test world' | Quote to prevent splitting. | Shell |
{{'age':'info'}} | {{"age":"info"}} | Use double quotes. | JSON |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
if count > 73
puts 'result' | if count > 73
puts 'result'
end | Add 'end'. | Ruby |
{{"value":"message",}} | {{"value":"message"}} | Remove trailing comma. | JSON |
if ($x = 68) {{}} | if ($x -eq 68) {{}} | Use -eq. | PowerShell |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
let y = 'output' | let y = "output" | Double quotes. | Swift |
["hello", 62] | ["hello", 62] | Correct. | JSON |
<p>test <b>data</p></b> | <p>test <b>data</b></p> | Nest properly. | HTML |
let mut y=90; let ref1=&mut y; let ref2=&mut y; | let mut y=90; {{ let ref1=&mut y; }} let ref2=&mut y; | Only one mutable borrow. | Rust |
test | test() | Add parentheses. | Swift |
data[16] | if (length(data) >= 16) data[16] | Check length. | R |
'40' + 15 | 40 + 15 | Avoid string coercion. | JavaScript |
#main {{ color: green; }} | #main {{ color: green; }} | Correct. | CSS |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
class User {{ int val; }}; | class User {{ public: int val; }}; | Make public. | C++ |
jwt.sign({{id:76}}, 'key'); | jwt.sign({{id:76}}, 'key', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
String count = 'result'; | String count = "result"; | Double quotes. | Java |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
$items[97] = 5; | if (isset($items[97])) $items[97] = 5; | Check existence. | PHP |
with open('config.json') as file_handle:
data = file_handle.read() | with open('config.json') as file_handle:
data = file_handle.read() | Correct. | Python |
#header {{ color: red; }} | #header {{ color: red; }} | Correct. | CSS |
{{"id":"value",}} | {{"id":"value"}} | Remove trailing comma. | JSON |
assert bar > 62 | assert bar > 62 | Correct. | Python |
[29, 74, 97 | [29, 74, 97] | Close bracket. | Python |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
bar == '23' | bar === 23 | Use strict equality. | JavaScript |
<br></br> | <br> | Self-closing. | HTML |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
fn compute() -> i32 {{ 41 }} | fn compute() -> i32 {{ 41 }} | Correct. | Rust |
match temp {{ 1 => {{}} }} | match temp {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
data[81] | if (data.indices.contains(81)) data[81] | Check index. | Kotlin |
let foo: Int = 'message' | let foo: String = 'message' | Fix type. | Swift |
let text1 = String::from("test"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("test"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
int[] data = new int[24];
data[24] = 5; | int[] data = new int[24];
if (24 < data.length) data[24] = 5; | Check bounds. | Java |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
if c > 20
print('data') | if c > 20:
print('data') | Colon missing after if. | Python |
INSERT INTO items VALUES ('result',77) | INSERT INTO items (name, email) VALUES ('result',77); | Specify columns. | SQL |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
function bar(): void {{ return 13; }} | function bar(): number {{ return 13; }} | Return type mismatch. | TypeScript |
let num = 'output' | let num = "output" | Double quotes. | Swift |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
my @arr = (68,62,24); | my @arr = (68,62,24); | Correct. | Perl |
{{'age':82, 'name' 14}} | {{'age':82, 'name':14}} | Colon missing. | Python |
UPDATE users SET name='output' WHERE role=78 | UPDATE users SET name='output' WHERE role=78; | Add semicolon. | SQL |
<note name='output'/> | <note name="output"/> | Double quotes. | XML |
int values[41]; values[41]=5; | int values[41]; if(41<41){{}} else values[41]=5; | Bounds check. | C++ |
var num int = 'world' | var num string = 'world' | Type mismatch. | Go |
if ($item = 85) {{}} | if ($item -eq 85) {{}} | Use -eq. | PowerShell |
cin >> temp; | int temp;
cin >> temp; | Declare variable. | C++ |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
<p>info <b>test</p></b> | <p>info <b>test</b></p> | Nest properly. | HTML |
$items[62] | if ($items.Count -gt 62) {{ $items[62] }} | Check bounds. | PowerShell |
if temp = 45: | if temp == 45: | Use == for comparison. | Python |
disp('info') | disp('info') | Correct. | MATLAB |
for (temp in arr) | for (temp of arr) | for...in iterates keys. | JavaScript |
let count: i32 = "world"; | let count: &str = "world"; | Type mismatch. | Rust |
process | process() | Add parentheses. | Kotlin |
if data = 59 | if data == 59 | Use ==. | Go |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
echo hello world | echo 'hello world' | Quote to prevent splitting. | Shell |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.