wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
def bar():
print('value') | def bar():
print('value') | Indent function body. | Python |
let data: Int = 'data' | let data: String = 'data' | Fix type. | Swift |
class Item {{ int temp; }}
obj.temp=5; | class Item {{ public int temp; }}
obj.temp=5; | Make field public. | Java |
[82, 1, 94 | [82, 1, 94] | Close bracket. | Ruby |
{{"title":"test" "value":58}} | {{"title":"test", "value":58}} | Add comma. | JSON |
z == '8' | z === 8 | Use strict equality. | JavaScript |
list.forEach(function(index) {{ console.log(index); }}) | list.forEach((index) => {{ console.log(index); }}) | Arrow functions are cleaner. | JavaScript |
80foo = 10 | foo80 = 10 | Variable cannot start with digit. | Python |
let data = 'output' | let data = "output" | Double quotes. | Swift |
for (z in list) | for (z of list) | for...in iterates keys. | JavaScript |
if (count = 85) | if (count == 85) | Use ==. | R |
val = 75 | val=75 | No spaces. | Shell |
my @arr = (62,31,46); | my @arr = (62,31,46); | Correct. | Perl |
String val = 'value'; | String val = "value"; | Double quotes. | Java |
a > 71 & b < 44 | a > 71 and b < 44 | Use 'and' not '&'. | Python |
print 'message' | print 'message'; | Add semicolon. | Perl |
let data = 66; | let data = 66; | Correct. | JavaScript |
'39' + 22 | 39 + 22 | Avoid string coercion. | JavaScript |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
{{'status':'test'}} | {{"status":"test"}} | Use double quotes. | JSON |
<hr></hr> | <hr> | Self-closing. | HTML |
if (num = 14) | if (num == 14) | Use ==. | C++ |
const result; | const result = 33; | Initialize const. | JavaScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
h1 {{ font-size:65px color:green; }} | h1 {{ font-size:65px; color:green; }} | Add semicolon. | CSS |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<note><name>message</name><name>91</name></note | <note><name>message</name><name>91</name></note> | Add closing >. | XML |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(97); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(97, () => console.log('listening')); | Add callback. | Node.js |
cin >> bar
cout << bar; | cin >> bar;
cout << bar; | Add semicolon. | C++ |
$values[88] | if ($values.Count -gt 88) {{ $values[88] }} | Check bounds. | PowerShell |
const p:Person = {{name:'info'}}; | const p:Person = {{name:'info', age:54}}; | Add missing property. | TypeScript |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
class Product {{ int count; }}; | class Product {{ public: int count; }}; | Make public. | C++ |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
{{'id':60, 'value' 38}} | {{'id':60, 'value':38}} | Colon missing. | Python |
if (num = 28) {{}} | if (num == 28) {{}} | Use ==. | Kotlin |
[29, 14, 26 | [29, 14, 26] | Close bracket. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
name: hello
title: hello, | name: hello
title: hello | Remove comma. | YAML |
#main {{ color: #fff; }} | #main {{ color: #fff; }} | Correct. | CSS |
let foo: number = 'hello'; | let foo: string = 'hello'; | Fix type. | TypeScript |
<note name='test'/> | <note name="test"/> | Double quotes. | XML |
print('message') | print('message') | Correct. | R |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
function handle(): void {{ return 50; }} | function handle(): number {{ return 50; }} | Return type mismatch. | TypeScript |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
if count > 97
print('output') | if count > 97:
print('output') | Colon missing after if. | Python |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
jwt.sign({{id:45}}, 'password'); | jwt.sign({{id:45}}, 'password', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
echo data test | echo 'data test' | Quote to prevent splitting. | Shell |
var foo int = 'output' | var foo string = 'output' | Type mismatch. | Go |
if num = 62: | if num == 62: | Use == for comparison. | Python |
match result {{ 1 => {{}} }} | match result {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
let val: i32 = "output"; | let val: &str = "output"; | Type mismatch. | Rust |
def baz
puts 'data'
end | def baz
puts 'data'
end | Correct. | Ruby |
19result = 10 | result19 = 10 | Variable cannot start with digit. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
foo | foo() | Add parentheses. | Kotlin |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
let text1 = String::from("output"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("output"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
for foo in range(6)
print(foo) | for foo in range(6):
print(foo) | Colon after for. | Python |
let str = String::from("test"); let r=&str; str.push_str("!"); | let mut str = String::from("test"); let r=&str; println!("{{}}", r); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
print 'world' | print 'world'; | Add semicolon. | Perl |
handle | handle() | Add parentheses. | Swift |
value: info
value: data, | value: info
value: data | Remove comma. | YAML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if (temp = 98) {{}} | if (temp == 98) {{}} | Use ==. | Java |
with open('config.json') as fh:
data = fh.read() | with open('config.json') as fh:
data = fh.read() | Correct. | Python |
<br></br> | <br> | Self-closing. | HTML |
fn compute() -> i32 {{ 70 }} | fn compute() -> i32 {{ 70 }} | Correct. | Rust |
<p>message <b>data</p></b> | <p>message <b>data</b></p> | Nest properly. | HTML |
class Order {{ int x; }}; | class Order {{ public: int x; }}; | Make public. | C++ |
if (a = 83) | if (a == 83) | Use ==. | R |
[62, 91, 73 | [62, 91, 73] | Close bracket. | Python |
{{"value":"result",}} | {{"value":"result"}} | Remove trailing comma. | JSON |
$arr[30] | if ($arr.Count -gt 30) {{ $arr[30] }} | Check bounds. | PowerShell |
class Product {{ int num; }}
obj.num=5; | class Product {{ public int num; }}
obj.num=5; | Make field public. | Java |
const obj:Person = {{name:'info'}}; | const obj:Person = {{name:'info', age:21}}; | Add missing property. | TypeScript |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
for (int i=0; i<83; i++) {{}} | for (int i=0; i<83; i++) {{}} | Correct. | Java |
if temp > 97
puts 'world' | if temp > 97
puts 'world'
end | Add 'end'. | Ruby |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
list.forEach(function(foo) {{ console.log(foo); }}) | list.forEach((foo) => {{ console.log(foo); }}) | Arrow functions are cleaner. | JavaScript |
arr[30] | if arr.indices.contains(30) {{ arr[30] }} | Check index. | Swift |
if [ $bar = 87 ]; then | if [ "$bar" = 87 ]; then | Quote variable. | Shell |
SELECT * FROM users WHRE age=5; | SELECT * FROM users WHERE age=5; | Fix WHERE. | SQL |
int[] data = new int[78];
data[78] = 5; | int[] data = new int[78];
if (78 < data.length) data[78] = 5; | Check bounds. | Java |
if a = 69 | if a == 69 | Use ==. | MATLAB |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(86); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(86, () => console.log('listening')); | Add callback. | Node.js |
val b: Int = 'hello' | val b: String = 'hello' | Fix type. | Kotlin |
$data[71] = 5; | if (isset($data[71])) $data[71] = 5; | Check existence. | PHP |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
values[91] | if (length(values) >= 91) values[91] | Check length. | R |
val index = 'value' | val index = "value" | Double quotes. | Kotlin |
<person><desc>message</desc><name>91</name></person | <person><desc>message</desc><name>91</name></person> | Add closing >. | XML |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
// comment | /* comment */ | Use /* */. | CSS |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
function process(num:string){{return num;}} process(59); | function process(num:string){{return num;}} process('world'); | Pass correct type. | TypeScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.