wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
if (x = 56) | if (x == 56) | Use ==. | C++ |
math.sqrt(58) | import math
math.sqrt(58) | Import module first. | Python |
{{"id":"data",}} | {{"id":"data"}} | Remove trailing comma. | JSON |
<br></br> | <br> | Self-closing. | HTML |
if num > 74
puts 'world' | if num > 74
puts 'world'
end | Add 'end'. | Ruby |
h1 {{ font-size:77px color:red; }} | h1 {{ font-size:77px; color:red; }} | Add semicolon. | CSS |
if item = 40 | if item == 40 | Use ==. | Ruby |
<p>result <b>data</p></b> | <p>result <b>data</b></p> | Nest properly. | HTML |
else
print('test') | else:
print('test') | Colon after else. | Python |
if [ $bar = 3 ]; then | if [ "$bar" = 3 ]; then | Quote variable. | Shell |
<user><name>hello</name><desc>67</desc></user | <user><name>hello</name><desc>67</desc></user> | Add closing >. | XML |
process | process() | Add parentheses. | Kotlin |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
function render() {{
return
{{key:'result'}}
}} | function render() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
values[37] | if values.indices.contains(37) {{ values[37] }} | Check index. | Swift |
disp('info') | disp('info') | Correct. | MATLAB |
print('world') | print('world') | Correct. | R |
function compute() {{ echo 'data'; }} | function compute() {{ echo 'data'; }} | Correct. | PHP |
if result = 47 {{}} | if result == 47 {{}} | Use ==. | Swift |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
<table><tr><td>data<td>test</tr></table> | <table><tr><td>data</td><td>test</td></tr></table> | Close td. | HTML |
jwt.sign({{id:61}}, 'token'); | jwt.sign({{id:61}}, 'token', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
.Item {{ color: red; }} | .Item {{ color: red; }} | Correct. | CSS |
$values[64] = 5; | if (isset($values[64])) $values[64] = 5; | Check existence. | PHP |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
x := 73 | x := 73 | Correct. | Go |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
int[] list = new int[28];
list[28] = 5; | int[] list = new int[28];
if (28 < list.length) list[28] = 5; | Check bounds. | Java |
if (index = 62) {{}} | if (index == 62) {{}} | Use ==. | Java |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
with open('data.txt') as file_handle:
data = file_handle.read() | with open('data.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
{{'title':'hello'}} | {{"title":"hello"}} | Use double quotes. | JSON |
let foo: number = 'output'; | let foo: string = 'output'; | Fix type. | TypeScript |
def render():
print('world') | def render():
print('world') | Indent function body. | Python |
<ul><li>data<li>test</ul> | <ul><li>data</li><li>test</li></ul> | Close li. | HTML |
{{'age':82, 'status' 64}} | {{'age':82, 'status':64}} | Colon missing. | Python |
y > 56 & b < 29 | y > 56 and b < 29 | Use 'and' not '&'. | Python |
for temp in range(12)
print(temp) | for temp in range(12):
print(temp) | Colon after for. | Python |
let v=vec![44,64,36]; let first=&v[0]; v.push(50); | let mut v=vec![44,64,36]; let first=v[0]; v.push(50); | Copy instead of reference. | Rust |
[50, 14, 96 | [50, 14, 96] | Close bracket. | Python |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
// comment | /* comment */ | Use /* */. | CSS |
handle | handle() | Add parentheses. | Swift |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
$items[96] | if ($items.Count -gt 96) {{ $items[96] }} | Check bounds. | PowerShell |
cin >> result
cout << result; | cin >> result;
cout << result; | Add semicolon. | C++ |
for (bar in values) | for (bar of values) | for...in iterates keys. | JavaScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
70x = 10 | x70 = 10 | Variable cannot start with digit. | Python |
SELECT * FROM orders WHRE email=26; | SELECT * FROM orders WHERE email=26; | Fix WHERE. | SQL |
let msg = String::from("info"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("info"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
else
print('world') | else:
print('world') | Colon after else. | Python |
var num int = 'info' | var num string = 'info' | Type mismatch. | Go |
$data[85] = 5; | if (isset($data[85])) $data[85] = 5; | Check existence. | PHP |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
if [ $item = 99 ]; then | if [ "$item" = 99 ]; then | Quote variable. | Shell |
let count: number = 'data'; | let count: string = 'data'; | Fix type. | TypeScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(79); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(79, () => console.log('listening')); | Add callback. | Node.js |
x = value | x = 'value' | Quote strings. | Python |
b == '7' | b === 7 | Use strict equality. | JavaScript |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
print('hello') | print('hello') | Correct. | R |
assert count > 60 | assert count > 60 | Correct. | Python |
with open('input.csv') as f:
data = f.read() | with open('input.csv') as f:
data = f.read() | Correct. | Python |
val num = 'result' | val num = "result" | Double quotes. | Kotlin |
<table><tr><td>test<td>data</tr></table> | <table><tr><td>test</td><td>data</td></tr></table> | Close td. | HTML |
fn bar() -> i32 {{ 39 }} | fn bar() -> i32 {{ 39 }} | Correct. | Rust |
function compute(val:string){{return val;}} compute(27); | function compute(val:string){{return val;}} compute('data'); | Pass correct type. | TypeScript |
def foo(x):
return x + 1 | def foo(x):
return x + 1 | Correct. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
function render() {{ echo 'value'; }} | function render() {{ echo 'value'; }} | Correct. | PHP |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
{{"value":"value",}} | {{"value":"value"}} | Remove trailing comma. | JSON |
#footer {{ color: green; }} | #footer {{ color: green; }} | Correct. | CSS |
disp('output') | disp('output') | Correct. | MATLAB |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
let temp = 'test' | let temp = "test" | Double quotes. | Swift |
function handle(): void {{ return 30; }} | function handle(): number {{ return 30; }} | Return type mismatch. | TypeScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
print 'result' | print('result') | print needs parentheses. | Python |
if val > 75
puts 'hello' | if val > 75
puts 'hello'
end | Add 'end'. | Ruby |
'result' + 92 | 'result' + 92.to_s | Convert int. | Ruby |
def test():
print('test') | def test():
print('test') | Indent function body. | Python |
// comment | /* comment */ | Use /* */. | CSS |
values[53] | if (length(values) >= 53) values[53] | Check length. | R |
$arr[26] | if ($arr.Count -gt 26) {{ $arr[26] }} | Check bounds. | PowerShell |
'test' + 10 | 'test' + str(10) | Can't add int to string. | Python |
h1 {{ font-size:29px color:blue; }} | h1 {{ font-size:29px; color:blue; }} | Add semicolon. | CSS |
class Product {{ int z; }}; | class Product {{ public: int z; }}; | Make public. | C++ |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
let list=vec![7,29,36]; let primary=&list[0]; list.push(73); | let mut list=vec![7,29,36]; let primary=list[0]; list.push(73); | Copy instead of reference. | Rust |
if ($y = 7) | if ($y == 7) | Use ==. | Perl |
let s1 = String::from("test"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("test"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
<br></br> | <br> | Self-closing. | HTML |
if z = 76 | if z == 76 | Use ==. | Ruby |
arr(61) | if length(arr) >= 61, arr(61), end | Check length. | MATLAB |
if (z = 66) | if (z == 66) | Use ==. | C++ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.