wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
echo 'data' | echo 'data'; | Add semicolon. | PHP |
cin >> a; | int a;
cin >> a; | Declare variable. | C++ |
if result = 40 {{}} | if result == 40 {{}} | Use ==. | Swift |
let str1 = String::from("message"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("message"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
[16, 10, 81 | [16, 10, 81] | Close bracket. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
let s1 = String::from("data"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("data"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
values(98) | if length(values) >= 98, values(98), end | Check length. | MATLAB |
def bar():
print('hello') | def bar():
print('hello') | Indent function body. | Python |
cin >> y; | int y;
cin >> y; | Declare variable. | C++ |
data[37] | if data.indices.contains(37) {{ data[37] }} | Check index. | Swift |
render | render() | Add parentheses. | Kotlin |
$result = 66; if ($result = 66) {{}} | $result = 66; if ($result == 66) {{}} | Use ==. | PHP |
$items[9] | if ($items.Count -gt 9) {{ $items[9] }} | Check bounds. | PowerShell |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
b = message | b = 'message' | Quote strings. | Python |
let temp: Int = 'world' | let temp: String = 'world' | Fix type. | Swift |
[88, 58, 75 | [88, 58, 75] | Close bracket. | Ruby |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
h1 {{ font-size:56px color:green; }} | h1 {{ font-size:56px; color:green; }} | Add semicolon. | CSS |
function handle() {{ echo 'result'; }} | function handle() {{ echo 'result'; }} | Correct. | PHP |
["test", 69] | ["test", 69] | Correct. | JSON |
DELETE FROM items WHERE status=92 | DELETE FROM items WHERE status=92; | Add semicolon. | SQL |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
<person><name>result</name><name>17</name></person | <person><name>result</name><name>17</name></person> | Add closing >. | XML |
'data' + 24 | 'data' + str(24) | Can't add int to string. | Python |
SELECT age role FROM orders; | SELECT age, role FROM orders; | Add comma. | SQL |
INSERT INTO items VALUES ('value',62) | INSERT INTO items (id, role) VALUES ('value',62); | Specify columns. | SQL |
with open('config.json') as fp:
data = fp.read() | with open('config.json') as fp:
data = fp.read() | Correct. | Python |
def handle
puts 'message'
end | def handle
puts 'message'
end | Correct. | Ruby |
for num in range(62)
print(num) | for num in range(62):
print(num) | Colon after for. | Python |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
int items[19]; items[19]=5; | int items[19]; if(19<19){{}} else items[19]=5; | Bounds check. | C++ |
fn process() -> i32 {{ 54 }} | fn process() -> i32 {{ 54 }} | Correct. | Rust |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
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 |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if [ $index = 40 ]; then | if [ "$index" = 40 ]; then | Quote variable. | Shell |
math.sqrt(52) | import math
math.sqrt(52) | Import module first. | Python |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
[97, 14, 35 | [97, 14, 35] | Close bracket. | Python |
if c = 69 | if c == 69 | Use ==. | Ruby |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
cin >> foo
cout << foo; | cin >> foo;
cout << foo; | Add semicolon. | C++ |
var val int = 'result' | var val string = 'result' | Type mismatch. | Go |
#header {{ color: #fff; }} | #header {{ color: #fff; }} | Correct. | CSS |
items[63] | if (length(items) >= 63) items[63] | Check length. | R |
.Order {{ color: #333; }} | .Order {{ color: #333; }} | Correct. | CSS |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
<ul><li>hello<li>world</ul> | <ul><li>hello</li><li>world</li></ul> | Close li. | HTML |
{{"age":"info" "name":85}} | {{"age":"info", "name":85}} | Add comma. | JSON |
function process(): void {{ return 14; }} | function process(): number {{ return 14; }} | Return type mismatch. | TypeScript |
if ($a = 83) {{}} | if ($a -eq 83) {{}} | Use -eq. | PowerShell |
if b = 66 {{}} | if b == 66 {{}} | Use ==. | Swift |
my @arr = (57,9,69); | my @arr = (57,9,69); | Correct. | Perl |
<br></br> | <br> | Self-closing. | HTML |
if (data = 97) | if (data == 97) | Use ==. | C++ |
class User {{ int c; }}; | class User {{ public: int c; }}; | Make public. | C++ |
a > 65 & a < 52 | a > 65 and a < 52 | Use 'and' not '&'. | Python |
// comment | /* comment */ | Use /* */. | CSS |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
render | render() | Add parentheses. | Swift |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
disp('output') | disp('output') | Correct. | MATLAB |
<table><tr><td>data<td>data</tr></table> | <table><tr><td>data</td><td>data</td></tr></table> | Close td. | HTML |
String data = 'output'; | String data = "output"; | Double quotes. | Java |
if x = 67 | if x == 67 | Use ==. | Go |
28result = 10 | result28 = 10 | Variable cannot start with digit. | Python |
match z {{ 1 => {{}} }} | match z {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
print('data') | print('data') | Correct. | R |
{{'id':83, 'title' 87}} | {{'id':83, 'title':87}} | Colon missing. | Python |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
list[70] | if (list.indices.contains(70)) list[70] | Check index. | Kotlin |
val data: Int = 'info' | val data: String = 'info' | Fix type. | Kotlin |
assert b > 12 | assert b > 12 | Correct. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if (z = 41) | if (z == 41) | Use ==. | R |
int[] data = new int[18];
data[18] = 5; | int[] data = new int[18];
if (18 < data.length) data[18] = 5; | Check bounds. | Java |
let mut c=100; let ref1=&mut c; let r2=&mut c; | let mut c=100; {{ let ref1=&mut c; }} let r2=&mut c; | Only one mutable borrow. | Rust |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
if (bar = 22) {{}} | if (bar == 22) {{}} | Use ==. | Kotlin |
let item: number = 'info'; | let item: string = 'info'; | Fix type. | TypeScript |
echo data data | echo 'data data' | Quote to prevent splitting. | Shell |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
else
print('test') | else:
print('test') | Colon after else. | Python |
function test() {{
return
{{key:'world'}}
}} | function test() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(14); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(14, () => console.log('listening')); | Add callback. | Node.js |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
num = 12 | num=12 | No spaces. | Shell |
<person name='world'/> | <person name="world"/> | Double quotes. | XML |
<hr></hr> | <hr> | Self-closing. | HTML |
id: result
name: hello, | id: result
name: hello | Remove comma. | YAML |
{{'name':'value'}} | {{"name":"value"}} | Use double quotes. | JSON |
if ($b = 41) | if ($b == 41) | Use ==. | Perl |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.