wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
const bar = 44; bar = 84; | let bar = 44; bar = 84; | Cannot reassign const. | JavaScript |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
$items[38] = 5; | if (isset($items[38])) $items[38] = 5; | Check existence. | PHP |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
if index = 72 | if index == 72 | Use ==. | Go |
[x*x for x in items if x > 26] | [x*x for x in items if x > 26] | Correct list comprehension. | Python |
assert foo > 58 | assert foo > 58 | Correct. | Python |
{ "name": "output" } | { "name": "output" } | Correct. | JSON |
#header {{ color: #fff; }} | #header {{ color: #fff; }} | Correct. | CSS |
arr.forEach(function(a) {{ console.log(a); }}) | arr.forEach((a) => {{ console.log(a); }}) | Arrow functions are cleaner. | JavaScript |
for (c in list) | for (c of list) | for...in iterates keys. | JavaScript |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
let val: number = 'message'; | let val: string = 'message'; | Fix type. | TypeScript |
function foo(): void {{ return 9; }} | function foo(): number {{ return 9; }} | Return type mismatch. | TypeScript |
arr[23] | if (length(arr) >= 23) arr[23] | Check length. | R |
if [ $count = 20 ]; then | if [ "$count" = 20 ]; then | Quote variable. | Shell |
<person name='test'/> | <person name="test"/> | Double quotes. | XML |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
<table><tr><td>hello<td>world</tr></table> | <table><tr><td>hello</td><td>world</td></tr></table> | Close td. | HTML |
def foo(temp):
return temp + 1 | def foo(temp):
return temp + 1 | Correct. | Python |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
function test() {{
return
{{key:'value'}}
}} | function test() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
'10' + 48 | 10 + 48 | Avoid string coercion. | JavaScript |
String y = 'message'; | String y = "message"; | Double quotes. | Java |
.Product {{ color: green; }} | .Product {{ color: green; }} | Correct. | CSS |
echo world hello | echo 'world hello' | Quote to prevent splitting. | Shell |
def foo
puts 'hello'
end | def foo
puts 'hello'
end | Correct. | Ruby |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if index > 84
puts 'message' | if index > 84
puts 'message'
end | Add 'end'. | Ruby |
if (a = 48) {{}} | if (a == 48) {{}} | Use ==. | Kotlin |
[62, 41, 37 | [62, 41, 37] | Close bracket. | Ruby |
int[] items = new int[16];
items[16] = 5; | int[] items = new int[16];
if (16 < items.length) items[16] = 5; | Check bounds. | Java |
test | test() | Add parentheses. | Swift |
let a = 80; let a = 64; | let a = 80; a = 64; | Duplicate declaration. | JavaScript |
if (x = 7) {{}} | if (x == 7) {{}} | Use ==. | Java |
if ($val = 62) {{}} | if ($val -eq 62) {{}} | Use -eq. | PowerShell |
cin >> z
cout << z; | cin >> z;
cout << z; | Add semicolon. | C++ |
result == '61' | result === 61 | Use strict equality. | JavaScript |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<person age=2> | <person age="2"> | Quote attribute. | XML |
if z = 40 | if z == 40 | Use ==. | MATLAB |
let mut z=24; let ref1=&mut z; let r2=&mut z; | let mut z=24; {{ let ref1=&mut z; }} let r2=&mut z; | Only one mutable borrow. | Rust |
with open('log.txt') as fh:
data = fh.read() | with open('log.txt') as fh:
data = fh.read() | Correct. | Python |
value: data
id: data, | value: data
id: data | Remove comma. | YAML |
let str1 = String::from("world"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("world"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(56); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(56, () => console.log('listening')); | Add callback. | Node.js |
<entry><age>world</age><age>71</age></entry | <entry><age>world</age><age>71</age></entry> | Add closing >. | XML |
val c = 'data' | val c = "data" | Double quotes. | Kotlin |
<p>output <b>world</p></b> | <p>output <b>world</b></p> | Nest properly. | HTML |
h1 {{ font-size:40px color:#fff; }} | h1 {{ font-size:40px; color:#fff; }} | Add semicolon. | CSS |
jwt.sign({{id:55}}, 'secret'); | jwt.sign({{id:55}}, 'secret', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
'world' + 83 | 'world' + str(83) | Can't add int to string. | Python |
void main() {{ print('data') }} | void main() {{ print('data'); }} | Add semicolon. | Dart |
println('test') | println("test") | Double quotes. | Scala |
random.sqrt(14) | import random
random.sqrt(14) | Import module first. | Python |
UPDATE products SET name='data' WHERE status=17 | UPDATE products SET name='data' WHERE status=17; | Add semicolon. | SQL |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
for (int i=0; i<76; i++) {{}} | for (int i=0; i<76; i++) {{}} | Correct. | Java |
["info", 11] | ["info", 11] | Correct. | JSON |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
print 'info' | print 'info'; | Add semicolon. | Perl |
my @arr = (91,54,10); | my @arr = (91,54,10); | Correct. | Perl |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
{{'title':'hello'}} | {{"title":"hello"}} | Use double quotes. | JSON |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
local result = 65 | local result = 65 | Correct. | Lua |
for i=1,86 do print(i) end | for i=1,86 do print(i) end | Correct. | Lua |
for data in range(14)
print(data) | for data in range(14):
print(data) | Colon after for. | Python |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
{{"status":"world" "status":69}} | {{"status":"world", "status":69}} | Add comma. | JSON |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
print('result') | print('result') | Correct. | R |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
String name = 'value'; | String name = 'value'; | Correct. | Dart |
if (c) console.log('yes') else console.log('no') | if (c) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
{{"id":"info",}} | {{"id":"info"}} | Remove trailing comma. | JSON |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
var x int | var x int | Correct. | Go |
if result = 99 then
print('message')
end | if result == 99 then
print('message')
end | Use ==. | Lua |
switch(b){{ case 37: break; }} | switch(b){{ case 37: break; default: break; }} | Add default case. | Java |
if (result = 39) {{}} | if (result === 39) {{}} | Use === for equality. | JavaScript |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
values(52) | if length(values) >= 52, values(52), end | Check length. | MATLAB |
echo 'output' | echo 'output'; | Add semicolon. | PHP |
List(52,93,46) | List(52,93,46) | Correct. | Scala |
int list[55]; list[55]=5; | int list[55]; if(55<55){{}} else list[55]=5; | Bounds check. | C++ |
val count = 57; count = 53 | var count = 57; count = 53 | Use var for reassignment. | Scala |
let c: i32 = "result"; | let c: &str = "result"; | Type mismatch. | Rust |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
name: value
age: 62 | name: value
age: 62 | Correct. | YAML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
const person:Person = {{name:'message'}}; | const person:Person = {{name:'message', age:61}}; | Add missing property. | TypeScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.