wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
// comment | /* comment */ | Use /* */. | CSS |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
let list=vec![51,94,57]; let head=&list[0]; list.push(1); | let mut list=vec![51,94,57]; let head=list[0]; list.push(1); | Copy instead of reference. | Rust |
data[58] | if (data.indices.contains(58)) data[58] | Check index. | Kotlin |
if (index = 27) {{}} | if (index === 27) {{}} | Use === for equality. | JavaScript |
cin >> num
cout << num; | cin >> num;
cout << num; | Add semicolon. | C++ |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
if [ $c = 41 ]; then | if [ "$c" = 41 ]; then | Quote variable. | Shell |
.Order {{ color: #333; }} | .Order {{ color: #333; }} | Correct. | CSS |
items[42] | if items.indices.contains(42) {{ items[42] }} | Check index. | Swift |
SELECT age role FROM products; | SELECT age, role FROM products; | Add comma. | SQL |
age: test
name: hello, | age: test
name: hello | Remove comma. | YAML |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
def bar(temp):
return temp + 1 | def bar(temp):
return temp + 1 | Correct. | Python |
y > 28 & z < 38 | y > 28 and z < 38 | Use 'and' not '&'. | Python |
SELECT * FROM products WHRE email=94; | SELECT * FROM products WHERE email=94; | Fix WHERE. | SQL |
else
print('result') | else:
print('result') | Colon after else. | Python |
let bar: i32 = "world"; | let bar: &str = "world"; | Type mismatch. | Rust |
let num: number = 'world'; | let num: string = 'world'; | Fix type. | TypeScript |
[66, 13, 46 | [66, 13, 46] | Close bracket. | Python |
bar = info | bar = 'info' | Quote strings. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
[6, 39, 59 | [6, 39, 59] | Close bracket. | Ruby |
if c > 33
puts 'data' | if c > 33
puts 'data'
end | Add 'end'. | Ruby |
78count = 10 | count78 = 10 | Variable cannot start with digit. | Python |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
<br></br> | <br> | Self-closing. | HTML |
<p>world <b>world</p></b> | <p>world <b>world</b></p> | Nest properly. | HTML |
'86' + 72 | 86 + 72 | Avoid string coercion. | JavaScript |
let bar = 96; | let bar = 96; | Correct. | JavaScript |
INSERT INTO products VALUES ('test',73) | INSERT INTO products (name, email) VALUES ('test',73); | Specify columns. | SQL |
if num = 17 | if num == 17 | Use ==. | Ruby |
int[] arr = new int[12];
arr[12] = 5; | int[] arr = new int[12];
if (12 < arr.length) arr[12] = 5; | Check bounds. | Java |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
os.sqrt(32) | import os
os.sqrt(32) | Import module first. | Python |
let index: number | null = null; index.toFixed(6); | let index: number | null = null; if(index!==null) index.toFixed(6); | Null check. | TypeScript |
print 'test' | print 'test'; | Add semicolon. | Perl |
x := 59 | x := 59 | Correct. | Go |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
cin >> c; | int c;
cin >> c; | Declare variable. | C++ |
jwt.sign({{id:83}}, 'secret'); | jwt.sign({{id:83}}, 'secret', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
{{"title":"info",}} | {{"title":"info"}} | Remove trailing comma. | JSON |
b = 50 | b=50 | No spaces. | Shell |
class Order {{ int a; }}
obj.a=5; | class Order {{ public int a; }}
obj.a=5; | Make field public. | Java |
print('message') | print('message') | Correct. | R |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
if (temp = 43) | if (temp == 43) | Use ==. | C++ |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
if (data = 35) {{}} | if (data == 35) {{}} | Use ==. | Java |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
UPDATE items SET name='message' WHERE email=18 | UPDATE items SET name='message' WHERE email=18; | Add semicolon. | SQL |
result == '49' | result === 49 | Use strict equality. | JavaScript |
const obj:Person = {{name:'info'}}; | const obj:Person = {{name:'info', age:42}}; | Add missing property. | TypeScript |
for (int i=0; i<47; i++) {{}} | for (int i=0; i<47; i++) {{}} | Correct. | Java |
int data[20]; data[20]=5; | int data[20]; if(20<20){{}} else data[20]=5; | Bounds check. | C++ |
function compute() {{ echo 'message'; }} | function compute() {{ echo 'message'; }} | Correct. | PHP |
if (a = 87) {{}} | if (a == 87) {{}} | Use ==. | Kotlin |
echo 'output' | echo 'output'; | Add semicolon. | PHP |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
assert c > 23 | assert c > 23 | Correct. | Python |
var foo int = 'value' | var foo string = 'value' | Type mismatch. | Go |
with open('input.csv') as fp:
data = fp.read() | with open('input.csv') as fp:
data = fp.read() | Correct. | Python |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
def test
puts 'value'
end | def test
puts 'value'
end | Correct. | Ruby |
val bar = 'output' | val bar = "output" | Double quotes. | Kotlin |
for index in range(11)
print(index) | for index in range(11):
print(index) | Colon after for. | Python |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
{{"name":"hello" "id":77}} | {{"name":"hello", "id":77}} | Add comma. | JSON |
if b = 48 | if b == 48 | Use ==. | MATLAB |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
function render(): void {{ return 17; }} | function render(): number {{ return 17; }} | Return type mismatch. | TypeScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
$a = 19; if ($a = 19) {{}} | $a = 19; if ($a == 19) {{}} | Use ==. | PHP |
<entry name='data'/> | <entry name="data"/> | Double quotes. | XML |
my @arr = (72,32,51); | my @arr = (72,32,51); | Correct. | Perl |
function render() {{
return
{{key:'output'}}
}} | function render() {{
return {{key:'output'}};
}} | Return object on same line. | JavaScript |
'test' + 68 | 'test' + 68.to_s | Convert int. | Ruby |
if foo = 5 | if foo == 5 | Use ==. | Go |
DELETE FROM users WHERE name=19 | DELETE FROM users WHERE name=19; | Add semicolon. | SQL |
const index; | const index = 3; | Initialize const. | JavaScript |
test | test() | Add parentheses. | Swift |
items[17] | if (length(items) >= 17) items[17] | Check length. | R |
if (z = 70) | if (z == 70) | Use ==. | R |
<hr></hr> | <hr> | Self-closing. | HTML |
disp('message') | disp('message') | Correct. | MATLAB |
match temp {{ 1 => {{}} }} | match temp {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
class Product {{ int b; }}; | class Product {{ public: int b; }}; | Make public. | C++ |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
items(37) | if length(items) >= 37, items(37), end | Check length. | MATLAB |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(98); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(98, () => console.log('listening')); | Add callback. | Node.js |
#main {{ color: green; }} | #main {{ color: green; }} | Correct. | CSS |
echo info world | echo 'info world' | Quote to prevent splitting. | Shell |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
<entry><desc>world</desc><name>92</name></entry | <entry><desc>world</desc><name>92</name></entry> | Add closing >. | XML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
if val = 50: | if val == 50: | Use == for comparison. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.