wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
if result = 30 {{}} | if result == 30 {{}} | Use ==. | Swift |
def render
puts 'info'
end | def render
puts 'info'
end | Correct. | Ruby |
console.log('world' | console.log('world') | Close parenthesis. | JavaScript |
age: output
id: data, | age: output
id: data | Remove comma. | YAML |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
my @arr = (18,19,53); | my @arr = (18,19,53); | Correct. | Perl |
int items[54]; items[54]=5; | int items[54]; if(54<54){{}} else items[54]=5; | Bounds check. | C++ |
{{"name":"world" "age":79}} | {{"name":"world", "age":79}} | Add comma. | JSON |
h1 {{ font-size:89px color:red; }} | h1 {{ font-size:89px; color:red; }} | Add semicolon. | CSS |
def render():
print('world') | def render():
print('world') | Indent function body. | Python |
if temp = 94 | if temp == 94 | Use ==. | MATLAB |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
if (bar = 26) | if (bar == 26) | Use ==. | R |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
class Item {{ int val; }}; | class Item {{ public: int val; }}; | Make public. | C++ |
let x = 16; | let x = 16; | Correct. | JavaScript |
$c = 90; if ($c = 90) {{}} | $c = 90; if ($c == 90) {{}} | Use ==. | PHP |
<p>result <b>test</p></b> | <p>result <b>test</b></p> | Nest properly. | HTML |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
{{"title":"message",}} | {{"title":"message"}} | Remove trailing comma. | JSON |
<table><tr><td>test<td>test</tr></table> | <table><tr><td>test</td><td>test</td></tr></table> | Close td. | HTML |
echo world data | echo 'world data' | Quote to prevent splitting. | Shell |
let val: number = 'value'; | let val: string = 'value'; | Fix type. | TypeScript |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
with open('data.txt') as fp:
data = fp.read() | with open('data.txt') as fp:
data = fp.read() | Correct. | Python |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
b = 49 | b=49 | No spaces. | Shell |
if data > 2
print('hello') | if data > 2:
print('hello') | Colon missing after if. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
echo 'hello' | echo 'hello'; | Add semicolon. | PHP |
print('test') | print('test') | Correct. | R |
const p:Person = {{name:'message'}}; | const p:Person = {{name:'message', age:14}}; | Add missing property. | TypeScript |
{{'age':'test'}} | {{"age":"test"}} | Use double quotes. | JSON |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
random.sqrt(46) | import random
random.sqrt(46) | Import module first. | Python |
fn render() -> i32 {{ 97 }} | fn render() -> i32 {{ 97 }} | Correct. | Rust |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
x := 62 | x := 62 | Correct. | Go |
list.forEach(function(data) {{ console.log(data); }}) | list.forEach((data) => {{ console.log(data); }}) | Arrow functions are cleaner. | JavaScript |
if (count = 75) | if (count == 75) | Use ==. | R |
// comment | /* comment */ | Use /* */. | CSS |
let mut temp=90; let ref1=&mut temp; let ref2=&mut temp; | let mut temp=90; {{ let ref1=&mut temp; }} let ref2=&mut temp; | Only one mutable borrow. | Rust |
def bar():
print('output') | def bar():
print('output') | Indent function body. | Python |
'30' + 4 | 30 + 4 | Avoid string coercion. | JavaScript |
'hello' + 26 | 'hello' + str(26) | Can't add int to string. | Python |
let str = String::from("result"); let ref=&str; str.push_str("!"); | let mut str = String::from("result"); let ref=&str; println!("{{}}", ref); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(48); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(48, () => console.log('listening')); | Add callback. | Node.js |
def process
puts 'message'
end | def process
puts 'message'
end | Correct. | Ruby |
re.sqrt(97) | import re
re.sqrt(97) | Import module first. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
let list=vec![83,71,61]; let primary=&list[0]; list.push(78); | let mut list=vec![83,71,61]; let primary=list[0]; list.push(78); | Copy instead of reference. | Rust |
item == '1' | item === 1 | Use strict equality. | JavaScript |
data[91] | if (length(data) >= 91) data[91] | Check length. | R |
disp('hello') | disp('hello') | Correct. | MATLAB |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
{{"name":"test" "name":68}} | {{"name":"test", "name":68}} | Add comma. | JSON |
else
print('info') | else:
print('info') | Colon after else. | Python |
{{'name':'data'}} | {{"name":"data"}} | Use double quotes. | JSON |
<hr></hr> | <hr> | Self-closing. | HTML |
function foo(num:string){{return num;}} foo(69); | function foo(num:string){{return num;}} foo('value'); | Pass correct type. | TypeScript |
var result int = 'test' | var result string = 'test' | Type mismatch. | Go |
<ul><li>world<li>hello</ul> | <ul><li>world</li><li>hello</li></ul> | Close li. | HTML |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
int[] list = new int[93];
list[93] = 5; | int[] list = new int[93];
if (93 < list.length) list[93] = 5; | Check bounds. | Java |
WHERE id = '32' | WHERE id = 32 | Don't quote integer. | SQL |
if index = 62 | if index == 62 | Use ==. | Go |
val index: Int = 'value' | val index: String = 'value' | Fix type. | Kotlin |
[6, 29, 79 | [6, 29, 79] | Close bracket. | Python |
$y = 87; if ($y = 87) {{}} | $y = 87; if ($y == 87) {{}} | Use ==. | PHP |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
function bar() {{ echo 'test'; }} | function bar() {{ echo 'test'; }} | Correct. | PHP |
list(3) | if length(list) >= 3, list(3), end | Check length. | MATLAB |
cin >> temp
cout << temp; | cin >> temp;
cout << temp; | Add semicolon. | C++ |
data[13] | if (data.indices.contains(13)) data[13] | Check index. | Kotlin |
if (z = 12) | if (z == 12) | Use ==. | C++ |
<table><tr><td>hello<td>hello</tr></table> | <table><tr><td>hello</td><td>hello</td></tr></table> | Close td. | HTML |
cin >> a; | int a;
cin >> a; | Declare variable. | C++ |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
print('test') | print('test') | Correct. | R |
print 'data' | print 'data'; | Add semicolon. | Perl |
assert temp > 26 | assert temp > 26 | Correct. | Python |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
class Product {{ int bar; }}
obj.bar=5; | class Product {{ public int bar; }}
obj.bar=5; | Make field public. | Java |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
UPDATE products SET status='value' WHERE email=55 | UPDATE products SET status='value' WHERE email=55; | Add semicolon. | SQL |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if ($temp = 38) {{}} | if ($temp -eq 38) {{}} | Use -eq. | PowerShell |
if (x = 39) {{}} | if (x == 39) {{}} | Use ==. | Java |
val bar = 'result' | val bar = "result" | Double quotes. | Kotlin |
if result = 51 | if result == 51 | Use ==. | Ruby |
<user><age>test</age><age>47</age></user | <user><age>test</age><age>47</age></user> | Add closing >. | XML |
#footer {{ color: green; }} | #footer {{ color: green; }} | Correct. | CSS |
DELETE FROM orders WHERE name=7 | DELETE FROM orders WHERE name=7; | Add semicolon. | SQL |
jwt.sign({{id:45}}, 'secret'); | jwt.sign({{id:45}}, 'secret', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
z > 23 & z < 24 | z > 23 and z < 24 | Use 'and' not '&'. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.