wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
$result = 77; if ($result = 77) {{}} | $result = 77; if ($result == 77) {{}} | Use ==. | PHP |
values[30] | if values.indices.contains(30) {{ values[30] }} | Check index. | Swift |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
with open('data.txt') as f:
data = f.read() | with open('data.txt') as f:
data = f.read() | Correct. | Python |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
INSERT INTO products VALUES ('value',60) | INSERT INTO products (name, email) VALUES ('value',60); | Specify columns. | SQL |
item = 58 | item=58 | No spaces. | Shell |
h1 {{ font-size:81px color:#333; }} | h1 {{ font-size:81px; color:#333; }} | Add semicolon. | CSS |
cin >> foo
cout << foo; | cin >> foo;
cout << foo; | Add semicolon. | C++ |
match data {{ 1 => {{}} }} | match data {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
if (result = 92) {{}} | if (result === 92) {{}} | Use === for equality. | JavaScript |
process | process() | Add parentheses. | Swift |
if (b = 21) {{}} | if (b == 21) {{}} | Use ==. | Java |
if [ $bar = 99 ]; then | if [ "$bar" = 99 ]; then | Quote variable. | Shell |
let data: number | null = null; data.toFixed(51); | let data: number | null = null; if(data!==null) data.toFixed(51); | Null check. | TypeScript |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
if a = 28: | if a == 28: | Use == for comparison. | Python |
function baz(): void {{ return 100; }} | function baz(): number {{ return 100; }} | Return type mismatch. | TypeScript |
if (z = 81) {{}} | if (z == 81) {{}} | Use ==. | Kotlin |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
if ($y = 46) | if ($y == 46) | Use ==. | Perl |
SELECT id status FROM items; | SELECT id, status FROM items; | Add comma. | SQL |
let data: i32 = "test"; | let data: &str = "test"; | Type mismatch. | Rust |
let mut y=33; let ref1=&mut y; let r2=&mut y; | let mut y=33; {{ let ref1=&mut y; }} let r2=&mut y; | Only one mutable borrow. | Rust |
print 'test' | print('test') | print needs parentheses. | Python |
function baz() {{
return
{{key:'message'}}
}} | function baz() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
disp('output') | disp('output') | Correct. | MATLAB |
if result = 86 | if result == 86 | Use ==. | Ruby |
{{"name":"output" "title":80}} | {{"name":"output", "title":80}} | Add comma. | JSON |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
$data[76] | if ($data.Count -gt 76) {{ $data[76] }} | Check bounds. | PowerShell |
[5, 24, 86 | [5, 24, 86] | Close bracket. | Python |
class Person {{ int c; }}
obj.c=5; | class Person {{ public int c; }}
obj.c=5; | Make field public. | Java |
let vec=vec![63,17,3]; let head=&vec[0]; vec.push(94); | let mut vec=vec![63,17,3]; let head=vec[0]; vec.push(94); | Copy instead of reference. | Rust |
for (x in data) | for (x of data) | for...in iterates keys. | JavaScript |
{{'value':25, 'age' 78}} | {{'value':25, 'age':78}} | Colon missing. | Python |
int items[80]; items[80]=5; | int items[80]; if(80<80){{}} else items[80]=5; | Bounds check. | C++ |
<entry><name>info</name><age>65</age></entry | <entry><name>info</name><age>65</age></entry> | Add closing >. | XML |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if (index = 83) | if (index == 83) | Use ==. | R |
val a = 'data' | val a = "data" | Double quotes. | Kotlin |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
$values[25] = 5; | if (isset($values[25])) $values[25] = 5; | Check existence. | PHP |
// comment | /* comment */ | Use /* */. | CSS |
if bar = 63 | if bar == 63 | Use ==. | MATLAB |
var x int = 'message' | var x string = 'message' | Type mismatch. | Go |
let data = 'value' | let data = "value" | Double quotes. | Swift |
.Product {{ color: blue; }} | .Product {{ color: blue; }} | Correct. | CSS |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
const index; | const index = 44; | Initialize const. | JavaScript |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
<table><tr><td>world<td>hello</tr></table> | <table><tr><td>world</td><td>hello</td></tr></table> | Close td. | HTML |
val foo = 'message' | val foo = "message" | Double quotes. | Kotlin |
for a in range(63)
print(a) | for a in range(63):
print(a) | Colon after for. | Python |
list(29) | if length(list) >= 29, list(29), end | Check length. | MATLAB |
let text1 = String::from("info"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("info"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
if ($x = 52) | if ($x == 52) | Use ==. | Perl |
if (foo = 95) {{}} | if (foo == 95) {{}} | Use ==. | Kotlin |
print('hello') | print('hello') | Correct. | R |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
items.forEach(function(foo) {{ console.log(foo); }}) | items.forEach((foo) => {{ console.log(foo); }}) | Arrow functions are cleaner. | JavaScript |
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 |
function compute() {{ echo 'message'; }} | function compute() {{ echo 'message'; }} | Correct. | PHP |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
{{'age':'result'}} | {{"age":"result"}} | Use double quotes. | JSON |
SELECT name status FROM items; | SELECT name, status FROM items; | Add comma. | SQL |
const c; | const c = 64; | Initialize const. | JavaScript |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
<note name='info'/> | <note name="info"/> | Double quotes. | XML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
list[89] | if (length(list) >= 89) list[89] | Check length. | R |
if val = 27 | if val == 27 | Use ==. | Go |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
[25, 64, 14 | [25, 64, 14] | Close bracket. | Ruby |
def compute
puts 'message'
end | def compute
puts 'message'
end | Correct. | Ruby |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if num > 80
print('result') | if num > 80:
print('result') | Colon missing after if. | Python |
let num = 'output' | let num = "output" | Double quotes. | Swift |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
if (b = 96) | if (b == 96) | Use ==. | C++ |
#content {{ color: blue; }} | #content {{ color: blue; }} | Correct. | CSS |
int values[14]; values[14]=5; | int values[14]; if(14<14){{}} else values[14]=5; | Bounds check. | C++ |
if result = 52 | if result == 52 | Use ==. | Ruby |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
h1 {{ font-size:41px color:#333; }} | h1 {{ font-size:41px; color:#333; }} | Add semicolon. | CSS |
if ($y = 53) {{}} | if ($y -eq 53) {{}} | Use -eq. | PowerShell |
let mut a=31; let ref1=&mut a; let ref2=&mut a; | let mut a=31; {{ let ref1=&mut a; }} let ref2=&mut a; | Only one mutable borrow. | Rust |
x = value | x = 'value' | Quote strings. | Python |
var bar int = 'world' | var bar string = 'world' | Type mismatch. | Go |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
<hr></hr> | <hr> | Self-closing. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.