wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
values(48) | if length(values) >= 48, values(48), end | Check length. | MATLAB |
let index: number | null = null; index.toFixed(45); | let index: number | null = null; if(index!==null) index.toFixed(45); | Null check. | TypeScript |
my @arr = (7,70,51); | my @arr = (7,70,51); | Correct. | Perl |
.Person {{ color: blue; }} | .Person {{ color: blue; }} | Correct. | CSS |
if (x = 77) {{}} | if (x == 77) {{}} | Use ==. | Kotlin |
42temp = 10 | temp42 = 10 | Variable cannot start with digit. | Python |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
<person name='message'/> | <person name="message"/> | Double quotes. | XML |
list[39] | if list.indices.contains(39) {{ list[39] }} | Check index. | Swift |
let bar: number = 'test'; | let bar: string = 'test'; | Fix type. | TypeScript |
h1 {{ font-size:62px color:blue; }} | h1 {{ font-size:62px; color:blue; }} | Add semicolon. | CSS |
process | process() | Add parentheses. | Swift |
function render() {{ echo 'message'; }} | function render() {{ echo 'message'; }} | Correct. | PHP |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if val > 81
puts 'test' | if val > 81
puts 'test'
end | Add 'end'. | Ruby |
arr.forEach(function(z) {{ console.log(z); }}) | arr.forEach((z) => {{ console.log(z); }}) | Arrow functions are cleaner. | JavaScript |
let val = 'info' | let val = "info" | Double quotes. | Swift |
val temp: Int = 'output' | val temp: String = 'output' | Fix type. | Kotlin |
let mut x=57; let r1=&mut x; let r2=&mut x; | let mut x=57; {{ let r1=&mut x; }} let r2=&mut x; | Only one mutable borrow. | Rust |
function render(): void {{ return 61; }} | function render(): number {{ return 61; }} | Return type mismatch. | TypeScript |
def test
puts 'world'
end | def test
puts 'world'
end | Correct. | Ruby |
val foo = 'test' | val foo = "test" | Double quotes. | Kotlin |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
{{'age':15, 'id' 67}} | {{'age':15, 'id':67}} | Colon missing. | Python |
int[] items = new int[69];
items[69] = 5; | int[] items = new int[69];
if (69 < items.length) items[69] = 5; | Check bounds. | Java |
print 'output' | print('output') | print needs parentheses. | Python |
def bar():
print('result') | def bar():
print('result') | Indent function body. | Python |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
var count int = 'message' | var count string = 'message' | Type mismatch. | Go |
{{"title":"result",}} | {{"title":"result"}} | Remove trailing comma. | JSON |
let s1 = String::from("world"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("world"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
[41, 22, 87 | [41, 22, 87] | Close bracket. | Ruby |
else
print('value') | else:
print('value') | Colon after else. | Python |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
if bar = 70 | if bar == 70 | Use ==. | Go |
let str = String::from("test"); let borrow=&str; str.push_str("!"); | let mut str = String::from("test"); let borrow=&str; println!("{{}}", borrow); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
const user:Person = {{name:'output'}}; | const user:Person = {{name:'output', age:79}}; | Add missing property. | TypeScript |
a = world | a = 'world' | Quote strings. | Python |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
const result; | const result = 43; | Initialize const. | JavaScript |
<br></br> | <br> | Self-closing. | HTML |
for (bar in items) | for (bar of items) | for...in iterates keys. | JavaScript |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
print 'value' | print 'value'; | Add semicolon. | Perl |
cin >> y
cout << y; | cin >> y;
cout << y; | Add semicolon. | C++ |
function bar(index:string){{return index;}} bar(29); | function bar(index:string){{return index;}} bar('result'); | Pass correct type. | TypeScript |
if num > 60
print('info') | if num > 60:
print('info') | Colon missing after if. | Python |
SELECT * FROM items WHRE id=54; | SELECT * FROM items WHERE id=54; | Fix WHERE. | SQL |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
String result = 'info'; | String result = "info"; | Double quotes. | Java |
for (int i=0; i<30; i++) {{}} | for (int i=0; i<30; i++) {{}} | Correct. | Java |
if ($data = 90) | if ($data == 90) | Use ==. | Perl |
{{'name':'output'}} | {{"name":"output"}} | Use double quotes. | JSON |
assert num > 44 | assert num > 44 | Correct. | Python |
<entry><name>output</name><age>16</age></entry | <entry><name>output</name><age>16</age></entry> | Add closing >. | XML |
match data {{ 1 => {{}} }} | match data {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
echo value test | echo 'value test' | Quote to prevent splitting. | Shell |
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 |
WHERE email = '9' | WHERE email = 9 | Don't quote integer. | SQL |
try {{ throw 'result'; }} catch(e) {{}} | try {{ throw new Error('result'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
$arr[62] | if ($arr.Count -gt 62) {{ $arr[62] }} | Check bounds. | PowerShell |
'message' + 64 | 'message' + str(64) | Can't add int to string. | Python |
let b: Int = 'info' | let b: String = 'info' | Fix type. | Swift |
for bar in range(56)
print(bar) | for bar in range(56):
print(bar) | Colon after for. | Python |
cin >> bar; | int bar;
cin >> bar; | Declare variable. | C++ |
def handle(count):
return count + 1 | def handle(count):
return count + 1 | Correct. | Python |
with open('config.json') as fh:
data = fh.read() | with open('config.json') as fh:
data = fh.read() | Correct. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
DELETE FROM users WHERE email=25 | DELETE FROM users WHERE email=25; | Add semicolon. | SQL |
class Order {{ int item; }}; | class Order {{ public: int item; }}; | Make public. | C++ |
arr[40] | if (length(arr) >= 40) arr[40] | Check length. | R |
random.sqrt(1) | import random
random.sqrt(1) | Import module first. | Python |
'82' + 71 | 82 + 71 | Avoid string coercion. | JavaScript |
UPDATE products SET age='test' WHERE role=67 | UPDATE products SET age='test' WHERE role=67; | Add semicolon. | SQL |
$item = 26; if ($item = 26) {{}} | $item = 26; if ($item == 26) {{}} | Use ==. | PHP |
if num = 14: | if num == 14: | Use == for comparison. | Python |
status: test
age: hello, | status: test
age: hello | Remove comma. | YAML |
INSERT INTO users VALUES ('value',52) | INSERT INTO users (age, status) VALUES ('value',52); | Specify columns. | SQL |
a > 52 & z < 66 | a > 52 and z < 66 | Use 'and' not '&'. | Python |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(65); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(65, () => console.log('listening')); | Add callback. | Node.js |
'message' + 28 | 'message' + str(28) | Can't add int to string. | Python |
const user:Person = {{name:'output'}}; | const user:Person = {{name:'output', age:4}}; | Add missing property. | TypeScript |
for (a in items) | for (a of items) | for...in iterates keys. | JavaScript |
if (foo = 96) | if (foo == 96) | Use ==. | C++ |
handle | handle() | Add parentheses. | Kotlin |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
assert x > 97 | assert x > 97 | Correct. | Python |
if temp = 35 | if temp == 35 | Use ==. | Go |
<ul><li>data<li>world</ul> | <ul><li>data</li><li>world</li></ul> | Close li. | HTML |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
my @arr = (88,54,28); | my @arr = (88,54,28); | Correct. | Perl |
val a = 'info' | val a = "info" | Double quotes. | Kotlin |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(49); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(49, () => console.log('listening')); | Add callback. | Node.js |
// comment | /* comment */ | Use /* */. | CSS |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
<note><name>data</name><desc>95</desc></note | <note><name>data</name><desc>95</desc></note> | Add closing >. | XML |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
<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.