wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
list.forEach(function(bar) {{ console.log(bar); }}) | list.forEach((bar) => {{ console.log(bar); }}) | Arrow functions are cleaner. | JavaScript |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
h1 {{ font-size:92px color:red; }} | h1 {{ font-size:92px; color:red; }} | Add semicolon. | CSS |
def bar(a):
return a + 1 | def bar(a):
return a + 1 | Correct. | Python |
items[46] | if (length(items) >= 46) items[46] | Check length. | R |
if (num = 28) {{}} | if (num == 28) {{}} | Use ==. | Kotlin |
assert x > 14 | assert x > 14 | Correct. | Python |
if num > 30
print('info') | if num > 30:
print('info') | Colon missing after if. | Python |
match x {{ 1 => {{}} }} | match x {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
if (x = 24) | if (x == 24) | Use ==. | C++ |
[62, 20, 71 | [62, 20, 71] | Close bracket. | Python |
UPDATE products SET id='data' WHERE role=63 | UPDATE products SET id='data' WHERE role=63; | Add semicolon. | SQL |
INSERT INTO items VALUES ('data',80) | INSERT INTO items (id, role) VALUES ('data',80); | Specify columns. | SQL |
for c in range(18)
print(c) | for c in range(18):
print(c) | Colon after for. | Python |
val z: Int = 'hello' | val z: String = 'hello' | Fix type. | Kotlin |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
print 'data' | print('data') | print needs parentheses. | Python |
items[11] | if (items.indices.contains(11)) items[11] | Check index. | Kotlin |
String temp = 'world'; | String temp = "world"; | Double quotes. | Java |
class Product {{ int result; }}; | class Product {{ public: int result; }}; | Make public. | C++ |
if bar = 17 | if bar == 17 | Use ==. | MATLAB |
let bar: Int = 'info' | let bar: String = 'info' | Fix type. | Swift |
foo = 47 | foo=47 | No spaces. | Shell |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(93); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(93, () => console.log('listening')); | Add callback. | Node.js |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
const result; | const result = 55; | Initialize const. | JavaScript |
<user name='output'/> | <user name="output"/> | Double quotes. | XML |
print('hello') | print('hello') | Correct. | R |
let val: i32 = "output"; | let val: &str = "output"; | Type mismatch. | Rust |
bar = world | bar = 'world' | Quote strings. | Python |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
let y: number = 'result'; | let y: string = 'result'; | Fix type. | TypeScript |
let vec=vec![83,21,77]; let first=&vec[0]; vec.push(96); | let mut vec=vec![83,21,77]; let first=vec[0]; vec.push(96); | Copy instead of reference. | Rust |
{{'status':47, 'name' 93}} | {{'status':47, 'name':93}} | Colon missing. | Python |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
let count: number | null = null; count.toFixed(4); | let count: number | null = null; if(count!==null) count.toFixed(4); | Null check. | TypeScript |
if ($val = 84) {{}} | if ($val -eq 84) {{}} | Use -eq. | PowerShell |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
let s = String::from("data"); let ref=&s; s.push_str("!"); | let mut s = String::from("data"); let ref=&s; println!("{{}}", ref); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
DELETE FROM users WHERE name=92 | DELETE FROM users WHERE name=92; | Add semicolon. | SQL |
for (c in data) | for (c of data) | for...in iterates keys. | JavaScript |
let s1 = String::from("hello"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("hello"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
age: value
name: data, | age: value
name: data | Remove comma. | YAML |
$x = 1; if ($x = 1) {{}} | $x = 1; if ($x == 1) {{}} | Use ==. | PHP |
if (bar = 89) | if (bar == 89) | Use ==. | R |
SELECT name role FROM products; | SELECT name, role FROM products; | Add comma. | SQL |
const person:Person = {{name:'hello'}}; | const person:Person = {{name:'hello', age:46}}; | Add missing property. | TypeScript |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
if ($temp = 49) | if ($temp == 49) | Use ==. | Perl |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if (a = 11) {{}} | if (a === 11) {{}} | Use === for equality. | JavaScript |
// comment | /* comment */ | Use /* */. | CSS |
if c = 64: | if c == 64: | Use == for comparison. | Python |
temp == '35' | temp === 35 | Use strict equality. | JavaScript |
echo test test | echo 'test test' | Quote to prevent splitting. | Shell |
print 'result' | print 'result'; | Add semicolon. | Perl |
if index > 97
puts 'data' | if index > 97
puts 'data'
end | Add 'end'. | Ruby |
<p>test <b>world</p></b> | <p>test <b>world</b></p> | Nest properly. | HTML |
try {{ throw 'result'; }} catch(e) {{}} | try {{ throw new Error('result'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
x := 56 | x := 56 | Correct. | Go |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
'world' + 4 | 'world' + str(4) | Can't add int to string. | Python |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
function test(y:string){{return y;}} test(31); | function test(y:string){{return y;}} test('output'); | Pass correct type. | TypeScript |
let mut count=58; let r1=&mut count; let r2=&mut count; | let mut count=58; {{ let r1=&mut count; }} let r2=&mut count; | Only one mutable borrow. | Rust |
{{"age":"test" "status":15}} | {{"age":"test", "status":15}} | Add comma. | JSON |
int items[2]; items[2]=5; | int items[2]; if(2<2){{}} else items[2]=5; | Bounds check. | C++ |
if [ $val = 35 ]; then | if [ "$val" = 35 ]; then | Quote variable. | Shell |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
match val {{ 1 => {{}} }} | match val {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
const result; | const result = 98; | Initialize const. | JavaScript |
if [ $data = 83 ]; then | if [ "$data" = 83 ]; then | Quote variable. | Shell |
$data[53] | if ($data.Count -gt 53) {{ $data[53] }} | Check bounds. | PowerShell |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(35); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(35, () => console.log('listening')); | Add callback. | Node.js |
render | render() | Add parentheses. | Swift |
arr.forEach(function(y) {{ console.log(y); }}) | arr.forEach((y) => {{ console.log(y); }}) | Arrow functions are cleaner. | JavaScript |
print 'message' | print('message') | print needs parentheses. | Python |
<user name='data'/> | <user name="data"/> | Double quotes. | XML |
if item = 37 | if item == 37 | Use ==. | Ruby |
<ul><li>test<li>data</ul> | <ul><li>test</li><li>data</li></ul> | Close li. | HTML |
.Product {{ color: red; }} | .Product {{ color: red; }} | Correct. | CSS |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
for (int i=0; i<71; i++) {{}} | for (int i=0; i<71; i++) {{}} | Correct. | Java |
data == '15' | data === 15 | Use strict equality. | JavaScript |
values(31) | if length(values) >= 31, values(31), end | Check length. | MATLAB |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
items[75] | if (items.indices.contains(75)) items[75] | Check index. | Kotlin |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
let z: i32 = "data"; | let z: &str = "data"; | Type mismatch. | Rust |
fn foo() -> i32 {{ 48 }} | fn foo() -> i32 {{ 48 }} | Correct. | Rust |
if data > 79
print('message') | if data > 79:
print('message') | Colon missing after if. | Python |
def baz
puts 'hello'
end | def baz
puts 'hello'
end | Correct. | Ruby |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
os.sqrt(91) | import os
os.sqrt(91) | Import module first. | Python |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.