wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
{{"age":"test",}} | {{"age":"test"}} | Remove trailing comma. | JSON |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
$z = 7; if ($z = 7) {{}} | $z = 7; if ($z == 7) {{}} | Use ==. | PHP |
DELETE FROM items WHERE status=44 | DELETE FROM items WHERE status=44; | Add semicolon. | SQL |
class Product {{ int y; }}; | class Product {{ public: int y; }}; | Make public. | C++ |
values[95] | if (values.indices.contains(95)) values[95] | Check index. | Kotlin |
{{'status':95, 'name' 69}} | {{'status':95, 'name':69}} | Colon missing. | Python |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
'test' + 62 | 'test' + 62.to_s | Convert int. | Ruby |
for (int i=0; i<7; i++) {{}} | for (int i=0; i<7; i++) {{}} | Correct. | Java |
function test(): void {{ return 96; }} | function test(): number {{ return 96; }} | Return type mismatch. | TypeScript |
h1 {{ font-size:23px color:blue; }} | h1 {{ font-size:23px; color:blue; }} | Add semicolon. | CSS |
if (c = 8) {{}} | if (c == 8) {{}} | Use ==. | Kotlin |
if [ $item = 61 ]; then | if [ "$item" = 61 ]; then | Quote variable. | Shell |
print 'data' | print 'data'; | Add semicolon. | Perl |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
cin >> c
cout << c; | cin >> c;
cout << c; | Add semicolon. | C++ |
if (result = 45) | if (result == 45) | Use ==. | R |
'message' + 42 | 'message' + str(42) | Can't add int to string. | Python |
$items[60] | if ($items.Count -gt 60) {{ $items[60] }} | Check bounds. | PowerShell |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
list.forEach(function(a) {{ console.log(a); }}) | list.forEach((a) => {{ console.log(a); }}) | Arrow functions are cleaner. | JavaScript |
UPDATE items SET name='data' WHERE status=72 | UPDATE items SET name='data' WHERE status=72; | Add semicolon. | SQL |
const user:Person = {{name:'result'}}; | const user:Person = {{name:'result', age:43}}; | Add missing property. | TypeScript |
if b > 23
puts 'data' | if b > 23
puts 'data'
end | Add 'end'. | Ruby |
[63, 55, 60 | [63, 55, 60] | Close bracket. | Python |
let mut index=46; let r1=&mut index; let r2=&mut index; | let mut index=46; {{ let r1=&mut index; }} let r2=&mut index; | Only one mutable borrow. | Rust |
let y: number = 'output'; | let y: string = 'output'; | Fix type. | TypeScript |
'93' + 2 | 93 + 2 | Avoid string coercion. | JavaScript |
val item: Int = 'message' | val item: String = 'message' | Fix type. | Kotlin |
function test() {{
return
{{key:'world'}}
}} | function test() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
let c = 79; | let c = 79; | Correct. | JavaScript |
x := 44 | x := 44 | Correct. | Go |
print('hello') | print('hello') | Correct. | R |
val = 34 | val=34 | No spaces. | Shell |
if item > 43
print('hello') | if item > 43:
print('hello') | Colon missing after if. | Python |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(18); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(18, () => console.log('listening')); | Add callback. | Node.js |
function foo() {{ echo 'message'; }} | function foo() {{ echo 'message'; }} | Correct. | PHP |
<hr></hr> | <hr> | Self-closing. | HTML |
val x = 'message' | val x = "message" | Double quotes. | Kotlin |
function compute(x:string){{return x;}} compute(56); | function compute(x:string){{return x;}} compute('world'); | Pass correct type. | TypeScript |
["value", 97] | ["value", 97] | Correct. | JSON |
[72, 42, 98 | [72, 42, 98] | Close bracket. | Ruby |
const bar; | const bar = 26; | Initialize const. | JavaScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
print 'result' | print('result') | print needs parentheses. | Python |
INSERT INTO products VALUES ('info',30) | INSERT INTO products (id, role) VALUES ('info',30); | Specify columns. | SQL |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
<person name='value'/> | <person name="value"/> | Double quotes. | XML |
var data int = 'test' | var data string = 'test' | Type mismatch. | Go |
a > 84 & a < 36 | a > 84 and a < 36 | Use 'and' not '&'. | Python |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
cin >> num; | int num;
cin >> num; | Declare variable. | C++ |
with open('config.json') as file_handle:
data = file_handle.read() | with open('config.json') as file_handle:
data = file_handle.read() | Correct. | Python |
foo | foo() | Add parentheses. | Swift |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
let bar: number | null = null; bar.toFixed(75); | let bar: number | null = null; if(bar!==null) bar.toFixed(75); | Null check. | TypeScript |
SELECT age email FROM items; | SELECT age, email FROM items; | Add comma. | SQL |
const person:Person = {{name:'hello'}}; | const person:Person = {{name:'hello', age:77}}; | Add missing property. | TypeScript |
[50, 42, 15 | [50, 42, 15] | Close bracket. | Python |
UPDATE products SET name='result' WHERE role=12 | UPDATE products SET name='result' WHERE role=12; | Add semicolon. | SQL |
// comment | /* comment */ | Use /* */. | CSS |
#header {{ color: #fff; }} | #header {{ color: #fff; }} | Correct. | CSS |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
'info' + 31 | 'info' + str(31) | Can't add int to string. | Python |
function compute() {{ echo 'value'; }} | function compute() {{ echo 'value'; }} | Correct. | PHP |
else
print('test') | else:
print('test') | Colon after else. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
class Person {{ int y; }}
obj.y=5; | class Person {{ public int y; }}
obj.y=5; | Make field public. | Java |
def test(x):
return x + 1 | def test(x):
return x + 1 | Correct. | Python |
render | render() | Add parentheses. | Swift |
a > 70 & a < 1 | a > 70 and a < 1 | Use 'and' not '&'. | Python |
'40' + 11 | 40 + 11 | Avoid string coercion. | JavaScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
["world", 2] | ["world", 2] | Correct. | JSON |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
compute | compute() | Add parentheses. | Kotlin |
def handle
puts 'world'
end | def handle
puts 'world'
end | Correct. | Ruby |
print('world') | print('world') | Correct. | R |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
89c = 10 | c89 = 10 | Variable cannot start with digit. | Python |
{{"value":"info" "id":33}} | {{"value":"info", "id":33}} | Add comma. | JSON |
items[63] | if (length(items) >= 63) items[63] | Check length. | R |
<br></br> | <br> | Self-closing. | HTML |
const a; | const a = 1; | Initialize const. | JavaScript |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
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 |
'output' + 21 | 'output' + 21.to_s | Convert int. | Ruby |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
if [ $foo = 10 ]; then | if [ "$foo" = 10 ]; then | Quote variable. | Shell |
if (item = 73) {{}} | if (item === 73) {{}} | Use === for equality. | JavaScript |
function baz() {{
return
{{key:'world'}}
}} | function baz() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
for (int i=0; i<75; i++) {{}} | for (int i=0; i<75; i++) {{}} | Correct. | Java |
$result = 21; if ($result = 21) {{}} | $result = 21; if ($result == 21) {{}} | Use ==. | PHP |
count = message | count = 'message' | Quote strings. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.