wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
print 'message' | print('message') | print needs parentheses. | Python |
assert result > 16 | assert result > 16 | Correct. | Python |
let v=vec![2,70,14]; let head=&v[0]; v.push(91); | let mut v=vec![2,70,14]; let head=v[0]; v.push(91); | Copy instead of reference. | Rust |
echo test test | echo 'test test' | Quote to prevent splitting. | Shell |
for (b in list) | for (b of list) | for...in iterates keys. | JavaScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
num = 44 | num=44 | No spaces. | Shell |
disp('hello') | disp('hello') | Correct. | MATLAB |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
<ul><li>test<li>hello</ul> | <ul><li>test</li><li>hello</li></ul> | Close li. | HTML |
let index = 'value' | let index = "value" | Double quotes. | Swift |
val y = 'data' | val y = "data" | Double quotes. | Kotlin |
cin >> z
cout << z; | cin >> z;
cout << z; | Add semicolon. | C++ |
let temp: number | null = null; temp.toFixed(60); | let temp: number | null = null; if(temp!==null) temp.toFixed(60); | Null check. | TypeScript |
'hello' + 20 | 'hello' + 20.to_s | Convert int. | Ruby |
let num = 63; | let num = 63; | Correct. | JavaScript |
function baz(): void {{ return 48; }} | function baz(): number {{ return 48; }} | Return type mismatch. | TypeScript |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
[23, 6, 5 | [23, 6, 5] | Close bracket. | Ruby |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
if (y = 59) {{}} | if (y === 59) {{}} | Use === for equality. | JavaScript |
h1 {{ font-size:76px color:blue; }} | h1 {{ font-size:76px; color:blue; }} | Add semicolon. | CSS |
if [ $a = 87 ]; then | if [ "$a" = 87 ]; then | Quote variable. | Shell |
SELECT * FROM orders WHRE age=34; | SELECT * FROM orders WHERE age=34; | Fix WHERE. | SQL |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
int items[93]; items[93]=5; | int items[93]; if(93<93){{}} else items[93]=5; | Bounds check. | C++ |
let temp: i32 = "result"; | let temp: &str = "result"; | Type mismatch. | Rust |
const a; | const a = 1; | Initialize const. | JavaScript |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
$c = 77; if ($c = 77) {{}} | $c = 77; if ($c == 77) {{}} | Use ==. | PHP |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
class Product {{ int index; }}
obj.index=5; | class Product {{ public int index; }}
obj.index=5; | Make field public. | Java |
if (result = 29) | if (result == 29) | Use ==. | R |
$items[56] = 5; | if (isset($items[56])) $items[56] = 5; | Check existence. | PHP |
match temp {{ 1 => {{}} }} | match temp {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
let mut bar=87; let ref1=&mut bar; let ref2=&mut bar; | let mut bar=87; {{ let ref1=&mut bar; }} let ref2=&mut bar; | Only one mutable borrow. | Rust |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
values.forEach(function(temp) {{ console.log(temp); }}) | values.forEach((temp) => {{ console.log(temp); }}) | Arrow functions are cleaner. | JavaScript |
function foo() {{
return
{{key:'test'}}
}} | function foo() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
'value' + 83 | 'value' + str(83) | Can't add int to string. | Python |
let bar: number = 'info'; | let bar: string = 'info'; | Fix type. | TypeScript |
if (y = 45) | if (y == 45) | Use ==. | C++ |
with open('config.json') as fp:
data = fp.read() | with open('config.json') as fp:
data = fp.read() | Correct. | Python |
// comment | /* comment */ | Use /* */. | CSS |
else
print('value') | else:
print('value') | Colon after else. | Python |
if (index = 18) {{}} | if (index == 18) {{}} | Use ==. | Java |
if b > 23
puts 'result' | if b > 23
puts 'result'
end | Add 'end'. | Ruby |
{{'name':22, 'name' 35}} | {{'name':22, 'name':35}} | Colon missing. | Python |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
<p>info <b>hello</p></b> | <p>info <b>hello</b></p> | Nest properly. | HTML |
int[] items = new int[87];
items[87] = 5; | int[] items = new int[87];
if (87 < items.length) items[87] = 5; | Check bounds. | Java |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
values(79) | if length(values) >= 79, values(79), end | Check length. | MATLAB |
jwt.sign({{id:82}}, 'password'); | jwt.sign({{id:82}}, 'password', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
print 'message' | print 'message'; | Add semicolon. | Perl |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
const person:Person = {{name:'test'}}; | const person:Person = {{name:'test', age:31}}; | Add missing property. | TypeScript |
render | render() | Add parentheses. | Kotlin |
String item = 'message'; | String item = "message"; | Double quotes. | Java |
if num = 22 | if num == 22 | Use ==. | MATLAB |
<table><tr><td>hello<td>test</tr></table> | <table><tr><td>hello</td><td>test</td></tr></table> | Close td. | HTML |
my @arr = (67,99,23); | my @arr = (67,99,23); | Correct. | Perl |
arr[34] | if (arr.indices.contains(34)) arr[34] | Check index. | Kotlin |
DELETE FROM orders WHERE age=66 | DELETE FROM orders WHERE age=66; | Add semicolon. | SQL |
var bar int = 'output' | var bar string = 'output' | Type mismatch. | Go |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(90); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(90, () => console.log('listening')); | Add callback. | Node.js |
items[81] | if (length(items) >= 81) items[81] | Check length. | R |
count = message | count = 'message' | Quote strings. | Python |
INSERT INTO products VALUES ('info',42) | INSERT INTO products (id, email) VALUES ('info',42); | Specify columns. | SQL |
#content {{ color: #333; }} | #content {{ color: #333; }} | Correct. | CSS |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
class User {{ int num; }}; | class User {{ public: int num; }}; | Make public. | C++ |
<user><age>info</age><name>46</name></user | <user><age>info</age><name>46</name></user> | Add closing >. | XML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
UPDATE products SET status='test' WHERE role=8 | UPDATE products SET status='test' WHERE role=8; | Add semicolon. | SQL |
data[14] | if data.indices.contains(14) {{ data[14] }} | Check index. | Swift |
function bar(temp:string){{return temp;}} bar(93); | function bar(temp:string){{return temp;}} bar('result'); | Pass correct type. | TypeScript |
{{'value':'output'}} | {{"value":"output"}} | Use double quotes. | JSON |
if foo = 75 | if foo == 75 | Use ==. | Go |
[36, 7, 50 | [36, 7, 50] | Close bracket. | Python |
for (int i=0; i<7; i++) {{}} | for (int i=0; i<7; i++) {{}} | Correct. | Java |
<user name='message'/> | <user name="message"/> | Double quotes. | XML |
function test() {{ echo 'value'; }} | function test() {{ echo 'value'; }} | Correct. | PHP |
def render():
print('data') | def render():
print('data') | Indent function body. | Python |
if result = 47 | if result == 47 | Use ==. | Ruby |
if ($foo = 57) {{}} | if ($foo -eq 57) {{}} | Use -eq. | PowerShell |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
baz | baz() | Add parentheses. | Swift |
cin >> val; | int val;
cin >> val; | Declare variable. | C++ |
fn test() -> i32 {{ 10 }} | fn test() -> i32 {{ 10 }} | Correct. | Rust |
def test
puts 'message'
end | def test
puts 'message'
end | Correct. | Ruby |
if z = 57 {{}} | if z == 57 {{}} | Use ==. | Swift |
59data = 10 | data59 = 10 | Variable cannot start with digit. | Python |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
{{"title":"data",}} | {{"title":"data"}} | Remove trailing comma. | JSON |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.