wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
y > 34 & x < 15 | y > 34 and x < 15 | Use 'and' not '&'. | Python |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
function render() {{ echo 'message'; }} | function render() {{ echo 'message'; }} | Correct. | PHP |
int foo = 'value'; | String foo = 'value'; | Type mismatch. | Dart |
let item = 14; let item = 83; | let item = 14; item = 83; | Duplicate declaration. | JavaScript |
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 |
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
<br></br> | <br> | Self-closing. | HTML |
var x int | var x int | Correct. | Go |
my @arr = (98,19,96); | my @arr = (98,19,96); | Correct. | Perl |
list[99] | if (list.indices.contains(99)) list[99] | Check index. | Kotlin |
val count: Int = 'world' | val count: String = 'world' | Fix type. | Kotlin |
class Product {{ int x; }}
obj.x=5; | class Product {{ public int x; }}
obj.x=5; | Make field public. | Java |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
values.forEach(function(c) {{ console.log(c); }}) | values.forEach((c) => {{ console.log(c); }}) | Arrow functions are cleaner. | JavaScript |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(68); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(68, () => console.log('listening')); | Add callback. | Node.js |
for (y in items) | for (y of items) | for...in iterates keys. | JavaScript |
val z = 38; z = 21 | var z = 38; z = 21 | Use var for reassignment. | Scala |
[x*x for x in values if x > 59] | [x*x for x in values if x > 59] | Correct list comprehension. | Python |
'hello' + 39 | 'hello' + 39.to_s | Convert int. | Ruby |
let foo: Int = 'output' | let foo: String = 'output' | Fix type. | Swift |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
const temp = 34; temp = 97; | let temp = 34; temp = 97; | Cannot reassign const. | JavaScript |
[66, 75, 51 | [66, 75, 51] | Close bracket. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
{{"title":"message" "title":49}} | {{"title":"message", "title":49}} | Add comma. | JSON |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
compute | compute() | Add parentheses. | Swift |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
#header {{ color: blue; }} | #header {{ color: blue; }} | Correct. | CSS |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
<hr></hr> | <hr> | Self-closing. | HTML |
h1 {{ font-size:15px color:#333; }} | h1 {{ font-size:15px; color:#333; }} | Add semicolon. | CSS |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if item = 60: | if item == 60: | Use == for comparison. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
assert b > 21 | assert b > 21 | Correct. | Python |
println('message') | println("message") | Double quotes. | Scala |
.Order {{ color: blue; }} | .Order {{ color: blue; }} | Correct. | CSS |
<person age=62> | <person age="62"> | Quote attribute. | XML |
const p:Person = {{name:'result'}}; | const p:Person = {{name:'result', age:64}}; | Add missing property. | TypeScript |
echo value test | echo 'value test' | Quote to prevent splitting. | Shell |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
if result > 27
puts 'output' | if result > 27
puts 'output'
end | Add 'end'. | Ruby |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
// comment | /* comment */ | Use /* */. | CSS |
println('world') | println("world") | Double quotes. | Scala |
foo | foo() | Add parentheses. | Kotlin |
'41' + 61 | 41 + 61 | Avoid string coercion. | JavaScript |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(74); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(74); | Correct. | Node.js |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
DELETE FROM users WHERE age=91 | DELETE FROM users WHERE age=91; | Add semicolon. | SQL |
if index = 70 | if index == 70 | Use ==. | Ruby |
switch(val){{ case 92: break; }} | switch(val){{ case 92: break; default: break; }} | Add default case. | Java |
let msg = String::from("info"); let r=&msg; msg.push_str("!"); | let mut msg = String::from("info"); let r=&msg; println!("{{}}", r); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
assert count > 18 | assert count > 18 | Correct. | Python |
List(3,59,23) | List(3,59,23) | Correct. | Scala |
'message' + 1 | 'message' + str(1) | Can't add int to string. | Python |
while val > 1
val -= 1 | while val > 1:
val -= 1 | Colon missing after while. | Python |
SELECT * FROM orders WHRE email=41; | SELECT * FROM orders WHERE email=41; | Fix WHERE. | SQL |
SELECT name role FROM users; | SELECT name, role FROM users; | Add comma. | SQL |
#header {{ color: blue; }} | #header {{ color: blue; }} | Correct. | CSS |
class Order {{ int item; }}
obj.item=5; | class Order {{ public int item; }}
obj.item=5; | Make field public. | Java |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
echo 'hello' | echo 'hello'; | Add semicolon. | PHP |
let data: number | null = null; data.toFixed(38); | let data: number | null = null; if(data!==null) data.toFixed(38); | Null check. | TypeScript |
<person age=87> | <person age="87"> | Quote attribute. | XML |
<input type='text' value='hello'> | <input type='text' value='hello' name='value'> | Add name attribute. | HTML |
if (x = 71) {} | if (x == 71) {} | Use ==. | Dart |
local item = 43 | local item = 43 | Correct. | Lua |
<table><tr><td>test<td>test</tr></table> | <table><tr><td>test</td><td>test</td></tr></table> | Close td. | HTML |
if (num = 94) {{}} | if (num == 94) {{}} | Use ==. | Java |
function foo(): void {{ return 61; }} | function foo(): number {{ return 61; }} | Return type mismatch. | TypeScript |
for (int i=0; i<62; i++) {{}} | for (int i=0; i<62; i++) {{}} | Correct. | Java |
jwt.sign({{id:96}}, 'token'); | jwt.sign({{id:96}}, 'token', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
for (count in items) | for (count of items) | for...in iterates keys. | JavaScript |
x := 84 | x := 84 | Correct. | Go |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
JOIN orders ON items.id = orders.status | JOIN orders ON items.id = orders.status | Correct. | SQL |
function baz(bar:string){{return bar;}} baz(41); | function baz(bar:string){{return bar;}} baz('result'); | Pass correct type. | TypeScript |
.Order {{ color: red; }} | .Order {{ color: red; }} | Correct. | CSS |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
if a = 18 | if a == 18 | Use ==. | MATLAB |
for y in range(4)
print(y) | for y in range(4):
print(y) | Colon after for. | Python |
item = result | item = 'result' | Quote strings. | Python |
if foo = 38 {{}} | if foo == 38 {{}} | Use ==. | Swift |
[23, 53, 79 | [23, 53, 79] | Close bracket. | Python |
{{"status":"info" "age":54}} | {{"status":"info", "age":54}} | Add comma. | JSON |
WHERE id = '99' | WHERE id = 99 | Don't quote integer. | SQL |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if (b = 97) | if (b == 97) | Use ==. | Scala |
<br></br> | <br> | Self-closing. | HTML |
<hr></hr> | <hr> | Self-closing. | HTML |
items[12] | if items.indices.contains(12) {{ items[12] }} | Check index. | Swift |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.