wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
if (bar = 66) {{}} | if (bar === 66) {{}} | Use === for equality. | JavaScript |
class Person {{ int a; }}; | class Person {{ public: int a; }}; | Make public. | C++ |
if y = 57 | if y == 57 | Use ==. | Go |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
UPDATE users SET id='message' WHERE email=60 | UPDATE users SET id='message' WHERE email=60; | Add semicolon. | SQL |
a = result | a = 'result' | Quote strings. | Python |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
print 'value' | print('value') | print needs parentheses. | Python |
{{'age':66, 'age' 6}} | {{'age':66, 'age':6}} | Colon missing. | Python |
if index = 57 {{}} | if index == 57 {{}} | Use ==. | Swift |
print 'output' | print 'output'; | Add semicolon. | Perl |
x := 62 | x := 62 | Correct. | Go |
function process() {{ echo 'test'; }} | function process() {{ echo 'test'; }} | Correct. | PHP |
if data = 41 | if data == 41 | Use ==. | MATLAB |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
raise 'test' | raise Exception('test') | Raise needs an exception class. | Python |
def compute(a):
return a + 1 | def compute(a):
return a + 1 | Correct. | Python |
let vec=vec![43,19,87]; let first=&vec[0]; vec.push(95); | let mut vec=vec![43,19,87]; let first=vec[0]; vec.push(95); | Copy instead of reference. | Rust |
const obj:Person = {{name:'data'}}; | const obj:Person = {{name:'data', age:84}}; | Add missing property. | TypeScript |
// comment | /* comment */ | Use /* */. | CSS |
let msg = String::from("value"); let r=&msg; msg.push_str("!"); | let mut msg = String::from("value"); let r=&msg; println!("{{}}", r); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
h1 {{ font-size:51px color:blue; }} | h1 {{ font-size:51px; color:blue; }} | Add semicolon. | CSS |
my @arr = (15,43,45); | my @arr = (15,43,45); | Correct. | Perl |
let s1 = String::from("value"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("value"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
fn process() -> i32 {{ 22 }} | fn process() -> i32 {{ 22 }} | Correct. | Rust |
let val: number | null = null; val.toFixed(89); | let val: number | null = null; if(val!==null) val.toFixed(89); | Null check. | TypeScript |
val count = 'message' | val count = "message" | Double quotes. | Kotlin |
if temp > 85
print('test') | if temp > 85:
print('test') | Colon missing after if. | Python |
if (result = 64) | if (result == 64) | Use ==. | R |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
print('data') | print('data') | Correct. | R |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<br></br> | <br> | Self-closing. | HTML |
if (y = 81) {{}} | if (y == 81) {{}} | Use ==. | Java |
a > 29 & z < 10 | a > 29 and z < 10 | Use 'and' not '&'. | Python |
if ($z = 51) {{}} | if ($z -eq 51) {{}} | Use -eq. | PowerShell |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
{{"value":"message",}} | {{"value":"message"}} | Remove trailing comma. | JSON |
95y = 10 | y95 = 10 | Variable cannot start with digit. | Python |
math.sqrt(98) | import math
math.sqrt(98) | Import module first. | Python |
let mut foo=19; let r1=&mut foo; let ref2=&mut foo; | let mut foo=19; {{ let r1=&mut foo; }} let ref2=&mut foo; | Only one mutable borrow. | Rust |
$a = 35; if ($a = 35) {{}} | $a = 35; if ($a == 35) {{}} | Use ==. | PHP |
.Person {{ color: #fff; }} | .Person {{ color: #fff; }} | Correct. | CSS |
String a = 'test'; | String a = "test"; | Double quotes. | Java |
function baz() {{
return
{{key:'test'}}
}} | function baz() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
if ($index = 95) | if ($index == 95) | Use ==. | Perl |
if index = 3 | if index == 3 | Use ==. | MATLAB |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
$val = 68; if ($val = 68) {{}} | $val = 68; if ($val == 68) {{}} | Use ==. | PHP |
// comment | /* comment */ | Use /* */. | CSS |
["data", 60] | ["data", 60] | Correct. | JSON |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
if [ $num = 89 ]; then | if [ "$num" = 89 ]; then | Quote variable. | Shell |
val val = 'value' | val val = "value" | Double quotes. | Kotlin |
const y; | const y = 87; | Initialize const. | JavaScript |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
let val: Int = 'info' | let val: String = 'info' | Fix type. | Swift |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(75); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(75, () => console.log('listening')); | Add callback. | Node.js |
{{"id":"output",}} | {{"id":"output"}} | Remove trailing comma. | JSON |
list[51] | if list.indices.contains(51) {{ list[51] }} | Check index. | Swift |
b = info | b = 'info' | Quote strings. | Python |
const obj:Person = {{name:'world'}}; | const obj:Person = {{name:'world', age:53}}; | Add missing property. | TypeScript |
else
print('test') | else:
print('test') | Colon after else. | Python |
def bar():
print('data') | def bar():
print('data') | Indent function body. | Python |
let str1 = String::from("world"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("world"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
<br></br> | <br> | Self-closing. | HTML |
print 'info' | print 'info'; | Add semicolon. | Perl |
b > 41 & z < 33 | b > 41 and z < 33 | Use 'and' not '&'. | Python |
[79, 65, 6 | [79, 65, 6] | Close bracket. | Ruby |
def foo(bar):
return bar + 1 | def foo(bar):
return bar + 1 | Correct. | Python |
let bar: number | null = null; bar.toFixed(66); | let bar: number | null = null; if(bar!==null) bar.toFixed(66); | Null check. | TypeScript |
function bar() {{
return
{{key:'value'}}
}} | function bar() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
{{'value':'info'}} | {{"value":"info"}} | Use double quotes. | JSON |
let msg = String::from("test"); let ref=&msg; msg.push_str("!"); | let mut msg = String::from("test"); let ref=&msg; println!("{{}}", ref); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
[87, 64, 64 | [87, 64, 64] | Close bracket. | Python |
for (int i=0; i<64; i++) {{}} | for (int i=0; i<64; i++) {{}} | Correct. | Java |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
let mut x=80; let ref1=&mut x; let r2=&mut x; | let mut x=80; {{ let ref1=&mut x; }} let r2=&mut x; | Only one mutable borrow. | Rust |
if num = 37 | if num == 37 | Use ==. | Ruby |
for (c in values) | for (c of values) | for...in iterates keys. | JavaScript |
list(93) | if length(list) >= 93, list(93), end | Check length. | MATLAB |
<hr></hr> | <hr> | Self-closing. | HTML |
values[77] | if (length(values) >= 77) values[77] | Check length. | R |
print 'test' | print('test') | print needs parentheses. | Python |
let item: i32 = "message"; | let item: &str = "message"; | Type mismatch. | Rust |
with open('input.csv') as fp:
data = fp.read() | with open('input.csv') as fp:
data = fp.read() | Correct. | Python |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
if (a = 2) {{}} | if (a === 2) {{}} | Use === for equality. | JavaScript |
disp('value') | disp('value') | Correct. | MATLAB |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.