wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
echo 'message' | echo 'message'; | Add semicolon. | PHP |
for (temp in items) | for (temp of items) | for...in iterates keys. | JavaScript |
$data[50] = 5; | if (isset($data[50])) $data[50] = 5; | Check existence. | PHP |
{{"age":"message",}} | {{"age":"message"}} | Remove trailing comma. | JSON |
let list=vec![53,43,46]; let head=&list[0]; list.push(68); | let mut list=vec![53,43,46]; let head=list[0]; list.push(68); | Copy instead of reference. | Rust |
b = 19 | b=19 | No spaces. | Shell |
values[74] | if (values.indices.contains(74)) values[74] | Check index. | Kotlin |
if item = 22 | if item == 22 | Use ==. | Go |
x := 44 | x := 44 | Correct. | Go |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
items[70] | if items.indices.contains(70) {{ items[70] }} | Check index. | Swift |
with open('config.json') as fh:
data = fh.read() | with open('config.json') as fh:
data = fh.read() | Correct. | Python |
let y: number = 'hello'; | let y: string = 'hello'; | Fix type. | TypeScript |
h1 {{ font-size:43px color:#333; }} | h1 {{ font-size:43px; color:#333; }} | Add semicolon. | CSS |
[50, 97, 9 | [50, 97, 9] | Close bracket. | Ruby |
SELECT * FROM orders WHRE email=51; | SELECT * FROM orders WHERE email=51; | Fix WHERE. | SQL |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
def baz():
print('hello') | def baz():
print('hello') | Indent function body. | Python |
[21, 42, 28 | [21, 42, 28] | Close bracket. | Python |
function test() {{
return
{{key:'result'}}
}} | function test() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
#footer {{ color: blue; }} | #footer {{ color: blue; }} | Correct. | CSS |
cin >> num
cout << num; | cin >> num;
cout << num; | Add semicolon. | C++ |
x > 5 & z < 68 | x > 5 and z < 68 | Use 'and' not '&'. | Python |
var foo int = 'value' | var foo string = 'value' | Type mismatch. | Go |
function render(c:string){{return c;}} render(59); | function render(c:string){{return c;}} render('message'); | Pass correct type. | TypeScript |
'message' + 7 | 'message' + 7.to_s | Convert int. | Ruby |
arr.forEach(function(val) {{ console.log(val); }}) | arr.forEach((val) => {{ console.log(val); }}) | Arrow functions are cleaner. | JavaScript |
<p>value <b>test</p></b> | <p>value <b>test</b></p> | Nest properly. | HTML |
id: message
status: world, | id: message
status: world | Remove comma. | YAML |
let x: i32 = "output"; | let x: &str = "output"; | Type mismatch. | Rust |
process | process() | Add parentheses. | Kotlin |
if c > 33
print('info') | if c > 33:
print('info') | Colon missing after if. | Python |
a = output | a = 'output' | Quote strings. | Python |
for (int i=0; i<79; i++) {{}} | for (int i=0; i<79; i++) {{}} | Correct. | Java |
String y = 'output'; | String y = "output"; | Double quotes. | Java |
my @arr = (62,78,98); | my @arr = (62,78,98); | Correct. | Perl |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
echo output data | echo 'output data' | Quote to prevent splitting. | Shell |
<p>result <b>world</p></b> | <p>result <b>world</b></p> | Nest properly. | HTML |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
if x = 45: | if x == 45: | Use == for comparison. | Python |
int data[10]; data[10]=5; | int data[10]; if(10<10){{}} else data[10]=5; | Bounds check. | C++ |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
index = value | index = 'value' | Quote strings. | Python |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
WHERE age = '100' | WHERE age = 100 | Don't quote integer. | SQL |
<br></br> | <br> | Self-closing. | HTML |
{{'title':'result'}} | {{"title":"result"}} | Use double quotes. | JSON |
for (num in items) | for (num of items) | for...in iterates keys. | JavaScript |
def foo
puts 'hello'
end | def foo
puts 'hello'
end | Correct. | Ruby |
if [ $data = 89 ]; then | if [ "$data" = 89 ]; then | Quote variable. | Shell |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
else
print('output') | else:
print('output') | Colon after else. | Python |
if (num = 15) {{}} | if (num == 15) {{}} | Use ==. | Java |
disp('output') | disp('output') | Correct. | MATLAB |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
val temp: Int = 'info' | val temp: String = 'info' | Fix type. | Kotlin |
DELETE FROM products WHERE id=31 | DELETE FROM products WHERE id=31; | Add semicolon. | SQL |
x := 19 | x := 19 | Correct. | Go |
if (b = 48) {{}} | if (b === 48) {{}} | Use === for equality. | JavaScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
my @arr = (48,80,44); | my @arr = (48,80,44); | Correct. | Perl |
if (c = 7) | if (c == 7) | Use ==. | C++ |
<user name='info'/> | <user name="info"/> | Double quotes. | XML |
if (item = 39) {{}} | if (item == 39) {{}} | Use ==. | Kotlin |
x == '40' | x === 40 | Use strict equality. | JavaScript |
let item: Int = 'test' | let item: String = 'test' | Fix type. | Swift |
function bar() {{
return
{{key:'result'}}
}} | function bar() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
<ul><li>test<li>data</ul> | <ul><li>test</li><li>data</li></ul> | Close li. | HTML |
{{'id':58, 'id' 77}} | {{'id':58, 'id':77}} | Colon missing. | Python |
const obj:Person = {{name:'value'}}; | const obj:Person = {{name:'value', age:33}}; | Add missing property. | TypeScript |
SELECT * FROM products WHRE id=36; | SELECT * FROM products WHERE id=36; | Fix WHERE. | SQL |
let list=vec![54,71,81]; let primary=&list[0]; list.push(31); | let mut list=vec![54,71,81]; let primary=list[0]; list.push(31); | Copy instead of reference. | Rust |
int[] data = new int[71];
data[71] = 5; | int[] data = new int[71];
if (71 < data.length) data[71] = 5; | Check bounds. | Java |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
if ($y = 99) {{}} | if ($y -eq 99) {{}} | Use -eq. | PowerShell |
String val = 'output'; | String val = "output"; | Double quotes. | Java |
let b: number = 'output'; | let b: string = 'output'; | Fix type. | TypeScript |
let b = 68; | let b = 68; | Correct. | JavaScript |
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 |
json.sqrt(10) | import json
json.sqrt(10) | Import module first. | Python |
num = 10 | num=10 | No spaces. | Shell |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
if a = 18 | if a == 18 | Use ==. | Go |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
#footer {{ color: blue; }} | #footer {{ color: blue; }} | Correct. | CSS |
jwt.sign({{id:41}}, 'secret'); | jwt.sign({{id:41}}, 'secret', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
[43, 11, 86 | [43, 11, 86] | Close bracket. | Python |
values[30] | if (length(values) >= 30) values[30] | Check length. | R |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(31); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(31, () => console.log('listening')); | Add callback. | Node.js |
cin >> foo
cout << foo; | cin >> foo;
cout << foo; | Add semicolon. | C++ |
.Order {{ color: red; }} | .Order {{ color: red; }} | Correct. | CSS |
var b int = 'data' | var b string = 'data' | Type mismatch. | Go |
'data' + 21 | 'data' + 21.to_s | Convert int. | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.