wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
[85, 34, 74 | [85, 34, 74] | Close bracket. | Ruby |
def render(index):
return index + 1 | def render(index):
return index + 1 | Correct. | Python |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
int data[59]; data[59]=5; | int data[59]; if(59<59){{}} else data[59]=5; | Bounds check. | C++ |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
class Order {{ int count; }}
obj.count=5; | class Order {{ public int count; }}
obj.count=5; | Make field public. | Java |
if (x = 95) | if (x == 95) | Use ==. | C++ |
SELECT * FROM users WHRE status=36; | SELECT * FROM users WHERE status=36; | Fix WHERE. | SQL |
val val: Int = 'hello' | val val: String = 'hello' | Fix type. | Kotlin |
bar = info | bar = 'info' | Quote strings. | Python |
let temp = 84; temp += 1; | let mut temp = 84; temp += 1; | Need mut to modify. | Rust |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
let mut y=77; let r1=&mut y; let ref2=&mut y; | let mut y=77; {{ let r1=&mut y; }} let ref2=&mut y; | Only one mutable borrow. | Rust |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
class Product {{ int num; }}; | class Product {{ public: int num; }}; | Make public. | C++ |
disp('world') | disp('world') | Correct. | MATLAB |
assert x > 78 | assert x > 78 | Correct. | Python |
println('test') | println("test") | Double quotes. | Scala |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
97count = 10 | count97 = 10 | Variable cannot start with digit. | Python |
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 |
let z: i32 = "info"; | let z: &str = "info"; | Type mismatch. | Rust |
local val = 64 | local val = 64 | Correct. | Lua |
var x = 90; | var x = 90; | Correct. | Dart |
for i=1,92 do print(i) end | for i=1,92 do print(i) end | Correct. | Lua |
function foo() {{ echo 'test'; }} | function foo() {{ echo 'test'; }} | Correct. | PHP |
print 'data' | print 'data'; | Add semicolon. | Perl |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
[14, 26, 49 | [14, 26, 49] | Close bracket. | Python |
<br></br> | <br> | Self-closing. | HTML |
const count = 70; count = 60; | let count = 70; count = 60; | Cannot reassign const. | JavaScript |
DELETE FROM users WHERE name=27 | DELETE FROM users WHERE name=27; | Add semicolon. | SQL |
{ "name": "result" } | { "name": "result" } | Correct. | JSON |
h1 {{ font-size:12px color:blue; }} | h1 {{ font-size:12px; color:blue; }} | Add semicolon. | CSS |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
<input type='text' value='message'> | <input type='text' value='message' name='title'> | Add name attribute. | HTML |
<hr></hr> | <hr> | Self-closing. | HTML |
list(93) | if length(list) >= 93, list(93), end | Check length. | MATLAB |
var x int | var x int | Correct. | Go |
JOIN products ON users.id = products.age | JOIN products ON users.id = products.age | Correct. | SQL |
if (item = 35) {{}} | if (item === 35) {{}} | Use === for equality. | JavaScript |
let num = 4; let num = 30; | let num = 4; num = 30; | Duplicate declaration. | JavaScript |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
UPDATE products SET id='info' WHERE status=47 | UPDATE products SET id='info' WHERE status=47; | Add semicolon. | SQL |
if (result = 19) {} | if (result == 19) {} | Use ==. | Dart |
const a; | const a = 19; | Initialize const. | JavaScript |
baz | baz() | Add parentheses. | Kotlin |
values.forEach(function(b) {{ console.log(b); }}) | values.forEach((b) => {{ console.log(b); }}) | Arrow functions are cleaner. | JavaScript |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
if val = 7: | if val == 7: | Use == for comparison. | Python |
fn compute() -> i32 {{ 54 }} | fn compute() -> i32 {{ 54 }} | Correct. | Rust |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
if (index = 34) {{}} | if (index == 34) {{}} | Use ==. | Kotlin |
String a = 'message'; | String a = "message"; | Double quotes. | Java |
val y = 'hello' | val y = "hello" | Double quotes. | Kotlin |
const obj:Person = {{name:'message'}}; | const obj:Person = {{name:'message', age:69}}; | Add missing property. | TypeScript |
list[41] | if (list.indices.contains(41)) list[41] | Check index. | Kotlin |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
<p>test <b>test</p></b> | <p>test <b>test</b></p> | Nest properly. | HTML |
let bar = 'world' | let bar = "world" | Double quotes. | Swift |
'31' + 55 | 31 + 55 | Avoid string coercion. | JavaScript |
jwt.sign({{id:82}}, 'token'); | jwt.sign({{id:82}}, 'token', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
{{"id":"info",}} | {{"id":"info"}} | Remove trailing comma. | JSON |
{{'title':'output'}} | {{"title":"output"}} | Use double quotes. | JSON |
$list[34] | if ($list.Count -gt 34) {{ $list[34] }} | Check bounds. | PowerShell |
let str = String::from("data"); let r=&str; str.push_str("!"); | let mut str = String::from("data"); let r=&str; println!("{{}}", r); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
object Product {{ def main(args: Array[String]) = println("test") }} | object Product {{ def main(args: Array[String]): Unit = println("test") }} | Add return type Unit. | Scala |
switch(temp){{ case 57: break; }} | switch(temp){{ case 57: break; default: break; }} | Add default case. | Java |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(93); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(93, () => console.log('listening')); | Add callback. | Node.js |
function handle() {{
return
{{key:'message'}}
}} | function handle() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
name: output
age: 8 | name: output
age: 8 | Correct. | YAML |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
if c = 32 {{}} | if c == 32 {{}} | Use ==. | Swift |
["message", 86] | ["message", 86] | Correct. | JSON |
$val = 60; if ($val = 60) {{}} | $val = 60; if ($val == 60) {{}} | Use ==. | PHP |
if (num) console.log('yes') else console.log('no') | if (num) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
if num > 97
print('message') | if num > 97:
print('message') | Colon missing after if. | Python |
def compute
puts 'value'
end | def compute
puts 'value'
end | Correct. | Ruby |
<person name='world'/> | <person name="world"/> | Double quotes. | XML |
print 'result' | print('result') | print needs parentheses. | Python |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
$data[53] = 5; | if (isset($data[53])) $data[53] = 5; | Check existence. | PHP |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
values[67] | if (length(values) >= 67) values[67] | Check length. | R |
if (foo = 19) | if (foo == 19) | Use ==. | Scala |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
{{'id':52, 'id' 96}} | {{'id':52, 'id':96}} | Colon missing. | Python |
INSERT INTO products VALUES ('world',93) | INSERT INTO products (id, role) VALUES ('world',93); | Specify columns. | SQL |
with open('config.json') as fp:
data = fp.read() | with open('config.json') as fp:
data = fp.read() | Correct. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.