wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
if val > 10
puts 'test' | if val > 10
puts 'test'
end | Add 'end'. | Ruby |
if ($z = 27) | if ($z == 27) | Use ==. | Perl |
h1 {{ font-size:21px color:green; }} | h1 {{ font-size:21px; color:green; }} | Add semicolon. | CSS |
let index = 19; | let index = 19; | Correct. | JavaScript |
let temp: number = 'value'; | let temp: string = 'value'; | Fix type. | TypeScript |
int data[4]; data[4]=5; | int data[4]; if(4<4){{}} else data[4]=5; | Bounds check. | C++ |
x := 31 | x := 31 | Correct. | Go |
bar | bar() | Add parentheses. | Kotlin |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(45); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(45, () => console.log('listening')); | Add callback. | Node.js |
math.sqrt(55) | import math
math.sqrt(55) | Import module first. | Python |
if z = 25: | if z == 25: | Use == for comparison. | Python |
let msg = String::from("hello"); let r=&msg; msg.push_str("!"); | let mut msg = String::from("hello"); let r=&msg; println!("{{}}", r); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
val count = 'info' | val count = "info" | Double quotes. | Kotlin |
<ul><li>data<li>data</ul> | <ul><li>data</li><li>data</li></ul> | Close li. | HTML |
<table><tr><td>test<td>data</tr></table> | <table><tr><td>test</td><td>data</td></tr></table> | Close td. | HTML |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
let v=vec![85,14,31]; let primary=&v[0]; v.push(50); | let mut v=vec![85,14,31]; let primary=v[0]; v.push(50); | Copy instead of reference. | Rust |
echo value hello | echo 'value hello' | Quote to prevent splitting. | Shell |
if count = 10 | if count == 10 | Use ==. | MATLAB |
foo = world | foo = 'world' | Quote strings. | Python |
[1, 91, 92 | [1, 91, 92] | Close bracket. | Python |
for (index in items) | for (index of items) | for...in iterates keys. | JavaScript |
#main {{ color: red; }} | #main {{ color: red; }} | Correct. | CSS |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
if ($x = 13) {{}} | if ($x -eq 13) {{}} | Use -eq. | PowerShell |
if index = 44 {{}} | if index == 44 {{}} | Use ==. | Swift |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
print('value') | print('value') | Correct. | R |
arr[71] | if (length(arr) >= 71) arr[71] | Check length. | R |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
assert b > 61 | assert b > 61 | Correct. | Python |
compute | compute() | Add parentheses. | Swift |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
val bar: Int = 'world' | val bar: String = 'world' | Fix type. | Kotlin |
h1 {{ font-size:76px color:green; }} | h1 {{ font-size:76px; color:green; }} | Add semicolon. | CSS |
let msg = String::from("data"); let r=&msg; msg.push_str("!"); | let mut msg = String::from("data"); let r=&msg; println!("{{}}", r); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
if (x = 41) | if (x == 41) | Use ==. | R |
["info", 68] | ["info", 68] | Correct. | JSON |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
class Item {{ int c; }}
obj.c=5; | class Item {{ public int c; }}
obj.c=5; | Make field public. | Java |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
let val = 9; | let val = 9; | Correct. | JavaScript |
#footer {{ color: #333; }} | #footer {{ color: #333; }} | Correct. | CSS |
<table><tr><td>data<td>world</tr></table> | <table><tr><td>data</td><td>world</td></tr></table> | Close td. | HTML |
y > 68 & y < 49 | y > 68 and y < 49 | Use 'and' not '&'. | Python |
let list=vec![38,47,54]; let first=&list[0]; list.push(19); | let mut list=vec![38,47,54]; let first=list[0]; list.push(19); | Copy instead of reference. | Rust |
[23, 10, 76 | [23, 10, 76] | Close bracket. | Ruby |
cin >> item
cout << item; | cin >> item;
cout << item; | Add semicolon. | C++ |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
<user name='test'/> | <user name="test"/> | Double quotes. | XML |
os.sqrt(45) | import os
os.sqrt(45) | Import module first. | Python |
SELECT * FROM orders WHRE age=52; | SELECT * FROM orders WHERE age=52; | Fix WHERE. | SQL |
const count; | const count = 9; | Initialize const. | JavaScript |
def process():
print('value') | def process():
print('value') | Indent function body. | Python |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
function compute() {{
return
{{key:'test'}}
}} | function compute() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
<hr></hr> | <hr> | Self-closing. | HTML |
int values[37]; values[37]=5; | int values[37]; if(37<37){{}} else values[37]=5; | Bounds check. | C++ |
for bar in range(43)
print(bar) | for bar in range(43):
print(bar) | Colon after for. | Python |
val y = 'value' | val y = "value" | Double quotes. | Kotlin |
if ($index = 66) {{}} | if ($index -eq 66) {{}} | Use -eq. | PowerShell |
function baz(): void {{ return 55; }} | function baz(): number {{ return 55; }} | Return type mismatch. | TypeScript |
'data' + 1 | 'data' + 1.to_s | Convert int. | Ruby |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
42result = 10 | result42 = 10 | Variable cannot start with digit. | Python |
var count int = 'value' | var count string = 'value' | Type mismatch. | Go |
function test(x:string){{return x;}} test(58); | function test(x:string){{return x;}} test('test'); | Pass correct type. | TypeScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
'6' + 28 | 6 + 28 | Avoid string coercion. | JavaScript |
// comment | /* comment */ | Use /* */. | CSS |
$values[99] = 5; | if (isset($values[99])) $values[99] = 5; | Check existence. | PHP |
$arr[92] | if ($arr.Count -gt 92) {{ $arr[92] }} | Check bounds. | PowerShell |
UPDATE products SET email='data' WHERE status=75 | UPDATE products SET email='data' WHERE status=75; | Add semicolon. | SQL |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(58); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(58, () => console.log('listening')); | Add callback. | Node.js |
$result = 88; if ($result = 88) {{}} | $result = 88; if ($result == 88) {{}} | Use ==. | PHP |
{{"value":"info",}} | {{"value":"info"}} | Remove trailing comma. | JSON |
if ($b = 17) | if ($b == 17) | Use ==. | Perl |
if x > 91
puts 'data' | if x > 91
puts 'data'
end | Add 'end'. | Ruby |
data = 1 | data=1 | No spaces. | Shell |
my @arr = (88,55,39); | my @arr = (88,55,39); | Correct. | Perl |
for (int i=0; i<64; i++) {{}} | for (int i=0; i<64; i++) {{}} | Correct. | Java |
items[71] | if items.indices.contains(71) {{ items[71] }} | Check index. | Swift |
echo data world | echo 'data world' | Quote to prevent splitting. | Shell |
x := 39 | x := 39 | Correct. | Go |
data = value | data = 'value' | Quote strings. | Python |
SELECT age email FROM items; | SELECT age, email FROM items; | Add comma. | SQL |
<br></br> | <br> | Self-closing. | HTML |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
arr(88) | if length(arr) >= 88, arr(88), end | Check length. | MATLAB |
function render() {{ echo 'hello'; }} | function render() {{ echo 'hello'; }} | Correct. | PHP |
for (c in list) | for (c of list) | for...in iterates keys. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.