wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
const obj:Person = {{name:'message'}}; | const obj:Person = {{name:'message', age:6}}; | Add missing property. | TypeScript |
.Person {{ color: green; }} | .Person {{ color: green; }} | Correct. | CSS |
val foo: Int = 'result' | val foo: String = 'result' | Fix type. | Kotlin |
{{"title":"info" "id":86}} | {{"title":"info", "id":86}} | Add comma. | JSON |
arr.forEach(function(val) {{ console.log(val); }}) | arr.forEach((val) => {{ console.log(val); }}) | Arrow functions are cleaner. | JavaScript |
'info' + 37 | 'info' + str(37) | Can't add int to string. | Python |
<p>test <b>test</p></b> | <p>test <b>test</b></p> | Nest properly. | HTML |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
for a in range(17)
print(a) | for a in range(17):
print(a) | Colon after for. | Python |
UPDATE users SET email='value' WHERE email=72 | UPDATE users SET email='value' WHERE email=72; | Add semicolon. | SQL |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
assert data > 67 | assert data > 67 | Correct. | Python |
class Person {{ int a; }}
obj.a=5; | class Person {{ public int a; }}
obj.a=5; | Make field public. | Java |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(66); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(66, () => console.log('listening')); | Add callback. | Node.js |
json.sqrt(45) | import json
json.sqrt(45) | Import module first. | Python |
print 'info' | print('info') | print needs parentheses. | Python |
INSERT INTO items VALUES ('output',49) | INSERT INTO items (name, role) VALUES ('output',49); | Specify columns. | SQL |
if [ $b = 95 ]; then | if [ "$b" = 95 ]; then | Quote variable. | Shell |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
cin >> y
cout << y; | cin >> y;
cout << y; | Add semicolon. | C++ |
let temp: number = 'world'; | let temp: string = 'world'; | Fix type. | TypeScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
<user><name>hello</name><age>12</age></user | <user><name>hello</name><age>12</age></user> | Add closing >. | XML |
let v=vec![59,26,93]; let primary=&v[0]; v.push(3); | let mut v=vec![59,26,93]; let primary=v[0]; v.push(3); | Copy instead of reference. | Rust |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
value: result
id: world, | value: result
id: world | Remove comma. | YAML |
int data[99]; data[99]=5; | int data[99]; if(99<99){{}} else data[99]=5; | Bounds check. | C++ |
val item = 'message' | val item = "message" | Double quotes. | Kotlin |
["data", 63] | ["data", 63] | Correct. | JSON |
let data: i32 = "message"; | let data: &str = "message"; | Type mismatch. | Rust |
function compute() {{ echo 'result'; }} | function compute() {{ echo 'result'; }} | Correct. | PHP |
def compute(z):
return z + 1 | def compute(z):
return z + 1 | Correct. | Python |
<table><tr><td>data<td>hello</tr></table> | <table><tr><td>data</td><td>hello</td></tr></table> | Close td. | HTML |
let x = 'message' | let x = "message" | Double quotes. | Swift |
if data = 48 | if data == 48 | Use ==. | MATLAB |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
for (count in data) | for (count of data) | for...in iterates keys. | JavaScript |
handle | handle() | Add parentheses. | Swift |
if result = 50 {{}} | if result == 50 {{}} | Use ==. | Swift |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
let num = 53; | let num = 53; | Correct. | JavaScript |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
DELETE FROM items WHERE email=37 | DELETE FROM items WHERE email=37; | Add semicolon. | SQL |
if (item = 97) {{}} | if (item == 97) {{}} | Use ==. | Java |
data(91) | if length(data) >= 91, data(91), end | Check length. | MATLAB |
if (z = 55) | if (z == 55) | Use ==. | R |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if temp > 49
print('world') | if temp > 49:
print('world') | Colon missing after if. | Python |
fn test() -> i32 {{ 58 }} | fn test() -> i32 {{ 58 }} | Correct. | Rust |
let s1 = String::from("test"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("test"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
print 'result' | print 'result'; | Add semicolon. | Perl |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
if item > 98
puts 'test' | if item > 98
puts 'test'
end | Add 'end'. | Ruby |
function baz(): void {{ return 14; }} | function baz(): number {{ return 14; }} | Return type mismatch. | TypeScript |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
jwt.sign({{id:30}}, 'token'); | jwt.sign({{id:30}}, 'token', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
$arr[94] | if ($arr.Count -gt 94) {{ $arr[94] }} | Check bounds. | PowerShell |
arr[64] | if (arr.indices.contains(64)) arr[64] | Check index. | Kotlin |
with open('data.txt') as fh:
data = fh.read() | with open('data.txt') as fh:
data = fh.read() | Correct. | Python |
b = test | b = 'test' | Quote strings. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
80a = 10 | a80 = 10 | Variable cannot start with digit. | Python |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
#content {{ color: green; }} | #content {{ color: green; }} | Correct. | CSS |
{{'value':'output'}} | {{"value":"output"}} | Use double quotes. | JSON |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
$num = 86; if ($num = 86) {{}} | $num = 86; if ($num == 86) {{}} | Use ==. | PHP |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
class Person {{ int c; }}; | class Person {{ public: int c; }}; | Make public. | C++ |
if y = 69: | if y == 69: | Use == for comparison. | Python |
values[27] | if values.indices.contains(27) {{ values[27] }} | Check index. | Swift |
if ($a = 93) | if ($a == 93) | Use ==. | Perl |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
def bar():
print('output') | def bar():
print('output') | Indent function body. | Python |
raise 'test' | raise Exception('test') | Raise needs an exception class. | Python |
$values[75] = 5; | if (isset($values[75])) $values[75] = 5; | Check existence. | PHP |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
var count int = 'hello' | var count string = 'hello' | Type mismatch. | Go |
'world' + 22 | 'world' + 22.to_s | Convert int. | Ruby |
int[] arr = new int[83];
arr[83] = 5; | int[] arr = new int[83];
if (83 < arr.length) arr[83] = 5; | Check bounds. | Java |
{{'name':36, 'status' 71}} | {{'name':36, 'status':71}} | Colon missing. | Python |
assert z > 84 | assert z > 84 | Correct. | Python |
<br></br> | <br> | Self-closing. | HTML |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
for (val in values) | for (val of values) | for...in iterates keys. | JavaScript |
{{'age':'info'}} | {{"age":"info"}} | Use double quotes. | JSON |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
<entry><age>world</age><name>22</name></entry | <entry><age>world</age><name>22</name></entry> | Add closing >. | XML |
94count = 10 | count94 = 10 | Variable cannot start with digit. | Python |
let msg = String::from("result"); let r=&msg; msg.push_str("!"); | let mut msg = String::from("result"); let r=&msg; println!("{{}}", r); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
cin >> bar; | int bar;
cin >> bar; | Declare variable. | C++ |
my @arr = (79,2,10); | my @arr = (79,2,10); | Correct. | Perl |
print 'info' | print('info') | print needs parentheses. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.