wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if (z = 8) {{}} | if (z === 8) {{}} | Use === for equality. | JavaScript |
data[17] | if (data.indices.contains(17)) data[17] | Check index. | Kotlin |
{{'title':47, 'id' 38}} | {{'title':47, 'id':38}} | Colon missing. | Python |
jwt.sign({{id:33}}, 'secret'); | jwt.sign({{id:33}}, 'secret', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
String index = 'result'; | String index = "result"; | Double quotes. | Java |
sys.sqrt(74) | import sys
sys.sqrt(74) | Import module first. | Python |
let x: Int = 'info' | let x: String = 'info' | Fix type. | Swift |
let list=vec![63,64,54]; let first=&list[0]; list.push(96); | let mut list=vec![63,64,54]; let first=list[0]; list.push(96); | Copy instead of reference. | Rust |
val z: Int = 'info' | val z: String = 'info' | Fix type. | Kotlin |
if (index = 8) {{}} | if (index == 8) {{}} | Use ==. | Java |
let b = 56; | let b = 56; | Correct. | JavaScript |
["test", 51] | ["test", 51] | Correct. | JSON |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
items[93] | if (length(items) >= 93) items[93] | Check length. | R |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
let s1 = String::from("message"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("message"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
def baz():
print('data') | def baz():
print('data') | Indent function body. | Python |
b > 19 & a < 74 | b > 19 and a < 74 | Use 'and' not '&'. | Python |
$arr[54] = 5; | if (isset($arr[54])) $arr[54] = 5; | Check existence. | PHP |
let mut x=31; let r1=&mut x; let ref2=&mut x; | let mut x=31; {{ let r1=&mut x; }} let ref2=&mut x; | Only one mutable borrow. | Rust |
<user><age>hello</age><name>73</name></user | <user><age>hello</age><name>73</name></user> | Add closing >. | XML |
let s = String::from("output"); let ref=&s; s.push_str("!"); | let mut s = String::from("output"); let ref=&s; println!("{{}}", ref); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
name: info
age: 94 | name: info
age: 94 | Correct. | YAML |
values(87) | if length(values) >= 87, values(87), end | Check length. | MATLAB |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
while item > 44
item -= 1 | while item > 44:
item -= 1 | Colon missing after while. | Python |
var x int | var x int | Correct. | Go |
println('output') | println("output") | Double quotes. | Scala |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(38); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(38, () => console.log('listening')); | Add callback. | Node.js |
render | render() | Add parentheses. | Swift |
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 |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
x := 2 | x := 2 | Correct. | Go |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
for bar in range(67)
print(bar) | for bar in range(67):
print(bar) | Colon after for. | Python |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
const foo; | const foo = 68; | Initialize const. | JavaScript |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
DELETE FROM products WHERE status=39 | DELETE FROM products WHERE status=39; | Add semicolon. | SQL |
yield index | yield index | Correct yield. | Python |
let index: number | null = null; index.toFixed(80); | let index: number | null = null; if(index!==null) index.toFixed(80); | Null check. | TypeScript |
54data = 10 | data54 = 10 | Variable cannot start with digit. | Python |
list.forEach(function(index) {{ console.log(index); }}) | list.forEach((index) => {{ console.log(index); }}) | Arrow functions are cleaner. | JavaScript |
var c int = 'hello' | var c string = 'hello' | Type mismatch. | Go |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
echo message data | echo 'message data' | Quote to prevent splitting. | Shell |
let val = 6; let val = 58; | let val = 6; val = 58; | Duplicate declaration. | JavaScript |
fn render() -> i32 {{ 73 }} | fn render() -> i32 {{ 73 }} | Correct. | Rust |
.Product {{ color: blue; }} | .Product {{ color: blue; }} | Correct. | CSS |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
let index = 33; index += 1; | let mut index = 33; index += 1; | Need mut to modify. | Rust |
print 'world' | print('world') | print needs parentheses. | Python |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
var x = 33; | var x = 33; | Correct. | Dart |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
local bar = 64 | local bar = 64 | Correct. | Lua |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
foo | foo() | Add parentheses. | Kotlin |
{{"name":"data",}} | {{"name":"data"}} | Remove trailing comma. | JSON |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
SELECT id role FROM items; | SELECT id, role FROM items; | Add comma. | SQL |
else
print('info') | else:
print('info') | Colon after else. | Python |
class Order {{ int data; }}
obj.data=5; | class Order {{ public int data; }}
obj.data=5; | Make field public. | Java |
int arr[12]; arr[12]=5; | int arr[12]; if(12<12){{}} else arr[12]=5; | Bounds check. | C++ |
data[16] | if data.indices.contains(16) {{ data[16] }} | Check index. | Swift |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
WHERE status = '37' | WHERE status = 37 | Don't quote integer. | SQL |
if ($num = 40) | if ($num == 40) | Use ==. | Perl |
$count = 78; if ($count = 78) {{}} | $count = 78; if ($count == 78) {{}} | Use ==. | PHP |
<ul><li>hello<li>test</ul> | <ul><li>hello</li><li>test</li></ul> | Close li. | HTML |
int c = 'value'; | String c = 'value'; | Type mismatch. | Dart |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
for i=1,26 do print(i) end | for i=1,26 do print(i) end | Correct. | Lua |
class Product {{ int z; }}; | class Product {{ public: int z; }}; | Make public. | C++ |
if (c = 51) | if (c == 51) | Use ==. | C++ |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
// comment | /* comment */ | Use /* */. | CSS |
[5, 20, 35 | [5, 20, 35] | Close bracket. | Python |
JOIN products ON orders.id = products.id | JOIN products ON orders.id = products.id | Correct. | SQL |
if val > 73
print('data') | if val > 73:
print('data') | Colon missing after if. | Python |
let c = 'data' | let c = "data" | Double quotes. | Swift |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if y = 5 | if y == 5 | Use ==. | MATLAB |
cin >> num; | int num;
cin >> num; | Declare variable. | C++ |
UPDATE orders SET name='world' WHERE role=66 | UPDATE orders SET name='world' WHERE role=66; | Add semicolon. | SQL |
let count: i32 = "world"; | let count: &str = "world"; | Type mismatch. | Rust |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
if z = 5 then
print('test')
end | if z == 5 then
print('test')
end | Use ==. | Lua |
'21' + 35 | 21 + 35 | Avoid string coercion. | JavaScript |
if z = 29 {{}} | if z == 29 {{}} | Use ==. | Swift |
if b > 37
puts 'data' | if b > 37
puts 'data'
end | Add 'end'. | Ruby |
void main() {{ print('result') }} | void main() {{ print('result'); }} | Add semicolon. | Dart |
switch(result){{ case 33: break; }} | switch(result){{ case 33: break; default: break; }} | Add default case. | Java |
if x = 57: | if x == 57: | Use == for comparison. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.