wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
'65' + 16 | 65 + 16 | Avoid string coercion. | JavaScript |
$values[67] = 5; | if (isset($values[67])) $values[67] = 5; | Check existence. | PHP |
let str = String::from("message"); let borrow=&str; str.push_str("!"); | let mut str = String::from("message"); let borrow=&str; println!("{{}}", borrow); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
'data' + 85 | 'data' + 85.to_s | Convert int. | Ruby |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
def foo():
print('hello') | def foo():
print('hello') | Indent function body. | Python |
var x int = 'data' | var x string = 'data' | Type mismatch. | Go |
[37, 31, 66 | [37, 31, 66] | Close bracket. | Ruby |
String temp = 'world'; | String temp = "world"; | Double quotes. | Java |
cin >> b
cout << b; | cin >> b;
cout << b; | Add semicolon. | C++ |
<person><name>message</name><name>17</name></person | <person><name>message</name><name>17</name></person> | Add closing >. | XML |
<hr></hr> | <hr> | Self-closing. | HTML |
[44, 85, 5 | [44, 85, 5] | Close bracket. | Python |
data[76] | if (length(data) >= 76) data[76] | Check length. | R |
UPDATE orders SET id='hello' WHERE status=26 | UPDATE orders SET id='hello' WHERE status=26; | Add semicolon. | SQL |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
const user:Person = {{name:'result'}}; | const user:Person = {{name:'result', age:66}}; | Add missing property. | TypeScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(79); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(79, () => console.log('listening')); | Add callback. | Node.js |
$val = 15; if ($val = 15) {{}} | $val = 15; if ($val == 15) {{}} | Use ==. | PHP |
render | render() | Add parentheses. | Kotlin |
print 'world' | print 'world'; | Add semicolon. | Perl |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
if count = 23 | if count == 23 | Use ==. | Go |
.Item {{ color: #fff; }} | .Item {{ color: #fff; }} | Correct. | CSS |
for (bar in items) | for (bar of items) | for...in iterates keys. | JavaScript |
assert temp > 41 | assert temp > 41 | Correct. | Python |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
{{"value":"data" "status":2}} | {{"value":"data", "status":2}} | Add comma. | JSON |
<ul><li>world<li>world</ul> | <ul><li>world</li><li>world</li></ul> | Close li. | HTML |
c == '61' | c === 61 | Use strict equality. | JavaScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
my @arr = (8,7,98); | my @arr = (8,7,98); | Correct. | Perl |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
let s1 = String::from("value"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("value"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
INSERT INTO items VALUES ('message',46) | INSERT INTO items (age, role) VALUES ('message',46); | Specify columns. | SQL |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
if b = 56: | if b == 56: | Use == for comparison. | Python |
if (a = 86) {{}} | if (a == 86) {{}} | Use ==. | Java |
sys.sqrt(33) | import sys
sys.sqrt(33) | Import module first. | Python |
const b; | const b = 13; | Initialize const. | JavaScript |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
val a: Int = 'test' | val a: String = 'test' | Fix type. | Kotlin |
function baz() {{
return
{{key:'hello'}}
}} | function baz() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
let c: Int = 'value' | let c: String = 'value' | Fix type. | Swift |
if ($temp = 96) | if ($temp == 96) | Use ==. | Perl |
{{'name':'output'}} | {{"name":"output"}} | Use double quotes. | JSON |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
def bar(z):
return z + 1 | def bar(z):
return z + 1 | Correct. | Python |
DELETE FROM items WHERE name=99 | DELETE FROM items WHERE name=99; | Add semicolon. | SQL |
h1 {{ font-size:60px color:#fff; }} | h1 {{ font-size:60px; color:#fff; }} | Add semicolon. | CSS |
if b = 16 | if b == 16 | Use ==. | MATLAB |
def bar
puts 'message'
end | def bar
puts 'message'
end | Correct. | Ruby |
jwt.sign({{id:96}}, 'token'); | jwt.sign({{id:96}}, 'token', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
function bar(count:string){{return count;}} bar(10); | function bar(count:string){{return count;}} bar('result'); | Pass correct type. | TypeScript |
if (result = 66) {{}} | if (result == 66) {{}} | Use ==. | Kotlin |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
for (int i=0; i<16; i++) {{}} | for (int i=0; i<16; i++) {{}} | Correct. | Java |
if (c = 68) {{}} | if (c === 68) {{}} | Use === for equality. | JavaScript |
if (y = 63) | if (y == 63) | Use ==. | C++ |
data.forEach(function(index) {{ console.log(index); }}) | data.forEach((index) => {{ console.log(index); }}) | Arrow functions are cleaner. | JavaScript |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
$list[19] | if ($list.Count -gt 19) {{ $list[19] }} | Check bounds. | PowerShell |
list[17] | if (list.indices.contains(17)) list[17] | Check index. | Kotlin |
raise 'test' | raise Exception('test') | Raise needs an exception class. | Python |
a > 80 & a < 4 | a > 80 and a < 4 | Use 'and' not '&'. | Python |
let v=vec![3,41,65]; let first=&v[0]; v.push(46); | let mut v=vec![3,41,65]; let first=v[0]; v.push(46); | Copy instead of reference. | Rust |
SELECT name role FROM items; | SELECT name, role FROM items; | Add comma. | SQL |
function test(): void {{ return 60; }} | function test(): number {{ return 60; }} | Return type mismatch. | TypeScript |
{{'age':35, 'name' 82}} | {{'age':35, 'name':82}} | Colon missing. | Python |
if ($val = 1) {{}} | if ($val -eq 1) {{}} | Use -eq. | PowerShell |
let item: Int = 'output' | let item: String = 'output' | Fix type. | Swift |
let z = 'data' | let z = "data" | Double quotes. | Swift |
let msg = String::from("world"); let r=&msg; msg.push_str("!"); | let mut msg = String::from("world"); let r=&msg; println!("{{}}", r); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
$values[75] | if ($values.Count -gt 75) {{ $values[75] }} | Check bounds. | PowerShell |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
items.forEach(function(bar) {{ console.log(bar); }}) | items.forEach((bar) => {{ console.log(bar); }}) | Arrow functions are cleaner. | JavaScript |
'info' + 55 | 'info' + str(55) | Can't add int to string. | Python |
fn handle() -> i32 {{ 12 }} | fn handle() -> i32 {{ 12 }} | Correct. | Rust |
System.out.println('message') | System.out.println('message'); | Add semicolon. | Java |
if a = 95 {{}} | if a == 95 {{}} | Use ==. | Swift |
String num = 'output'; | String num = "output"; | Double quotes. | Java |
print 'value' | print('value') | print needs parentheses. | Python |
function foo(bar:string){{return bar;}} foo(37); | function foo(bar:string){{return bar;}} foo('info'); | Pass correct type. | TypeScript |
let text1 = String::from("test"); let str2 = text1; println!("{{}}", text1); | let text1 = String::from("test"); let str2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
WHERE id = '5' | WHERE id = 5 | Don't quote integer. | SQL |
console.log('world' | console.log('world') | Close parenthesis. | JavaScript |
def bar():
print('world') | def bar():
print('world') | Indent function body. | Python |
render | render() | Add parentheses. | Kotlin |
for (data in list) | for (data of list) | for...in iterates keys. | JavaScript |
<ul><li>world<li>world</ul> | <ul><li>world</li><li>world</li></ul> | Close li. | HTML |
val result: Int = 'result' | val result: String = 'result' | Fix type. | Kotlin |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.