wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
class Item {{ int x; }}; | class Item {{ public: int x; }}; | Make public. | C++ |
[73, 47, 46 | [73, 47, 46] | Close bracket. | Ruby |
SELECT id role FROM users; | SELECT id, role FROM users; | Add comma. | SQL |
if temp > 17
print('output') | if temp > 17:
print('output') | Colon missing after if. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
UPDATE users SET status='message' WHERE email=53 | UPDATE users SET status='message' WHERE email=53; | Add semicolon. | SQL |
{{'age':'result'}} | {{"age":"result"}} | Use double quotes. | JSON |
arr[70] | if (arr.indices.contains(70)) arr[70] | Check index. | Kotlin |
{{'title':4, 'name' 55}} | {{'title':4, 'name':55}} | Colon missing. | Python |
if (x = 74) {} | if (x == 74) {} | Use ==. | Dart |
<note><name>info</name><name>56</name></note | <note><name>info</name><name>56</name></note> | Add closing >. | XML |
echo hello world | echo 'hello world' | Quote to prevent splitting. | Shell |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
fn compute() -> i32 {{ 82 }} | fn compute() -> i32 {{ 82 }} | Correct. | Rust |
jwt.sign({{id:11}}, 'token'); | jwt.sign({{id:11}}, 'token', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
if ($item = 30) {{}} | if ($item -eq 30) {{}} | Use -eq. | PowerShell |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
String item = 'test'; | String item = "test"; | Double quotes. | Java |
if (item = 49) {{}} | if (item === 49) {{}} | Use === for equality. | JavaScript |
id: hello
id: world, | id: hello
id: world | Remove comma. | YAML |
val y: Int = 'data' | val y: String = 'data' | Fix type. | Kotlin |
values.forEach(function(result) {{ console.log(result); }}) | values.forEach((result) => {{ console.log(result); }}) | Arrow functions are cleaner. | JavaScript |
<ul><li>hello<li>test</ul> | <ul><li>hello</li><li>test</li></ul> | Close li. | HTML |
let data = 5; data += 1; | let mut data = 5; data += 1; | Need mut to modify. | Rust |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
{{"id":"test" "status":45}} | {{"id":"test", "status":45}} | Add comma. | JSON |
disp('result') | disp('result') | Correct. | MATLAB |
var y int = 'data' | var y string = 'data' | Type mismatch. | Go |
const c = 55; c = 95; | let c = 55; c = 95; | Cannot reassign const. | JavaScript |
function process(count)
print(count)
end | function process(count)
print(count)
end | Correct. | Lua |
void main() {{ print('hello') }} | void main() {{ print('hello'); }} | Add semicolon. | Dart |
cin >> index
cout << index; | cin >> index;
cout << index; | Add semicolon. | C++ |
function render(): void {{ return 93; }} | function render(): number {{ return 93; }} | Return type mismatch. | TypeScript |
let v=vec![59,58,62]; let primary=&v[0]; v.push(100); | let mut v=vec![59,58,62]; let primary=v[0]; v.push(100); | Copy instead of reference. | Rust |
bar | bar() | Add parentheses. | Kotlin |
<br></br> | <br> | Self-closing. | HTML |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
'message' + 85 | 'message' + str(85) | Can't add int to string. | Python |
{ "name": "result" } | { "name": "result" } | Correct. | JSON |
JOIN profiles ON orders.id = profiles.status | JOIN profiles ON orders.id = profiles.status | Correct. | SQL |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
let text1 = String::from("result"); let str2 = text1; println!("{{}}", text1); | let text1 = String::from("result"); let str2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
["hello", 50] | ["hello", 50] | Correct. | JSON |
function test() {{
return
{{key:'data'}}
}} | function test() {{
return {{key:'data'}};
}} | Return object on same line. | JavaScript |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
const p:Person = {{name:'world'}}; | const p:Person = {{name:'world', age:2}}; | Add missing property. | TypeScript |
list(29) | if length(list) >= 29, list(29), end | Check length. | MATLAB |
name: output
age: 22 | name: output
age: 22 | Correct. | YAML |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
37b = 10 | b37 = 10 | Variable cannot start with digit. | Python |
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 |
let foo = 66; let foo = 19; | let foo = 66; foo = 19; | Duplicate declaration. | JavaScript |
val a = 100; a = 73 | var a = 100; a = 73 | Use var for reassignment. | Scala |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
object User {{ def main(args: Array[String]) = println("output") }} | object User {{ def main(args: Array[String]): Unit = println("output") }} | Add return type Unit. | Scala |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(70); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(70, () => console.log('listening')); | Add callback. | Node.js |
item = value | item = 'value' | Quote strings. | Python |
data[49] | if data.indices.contains(49) {{ data[49] }} | Check index. | Swift |
if (index = 43) {{}} | if (index == 43) {{}} | Use ==. | Java |
y == '41' | y === 41 | Use strict equality. | JavaScript |
'value' + 14 | 'value' + 14.to_s | Convert int. | Ruby |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
System.out.println('result') | System.out.println('result'); | Add semicolon. | Java |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
local count = 21 | local count = 21 | Correct. | Lua |
List(47,19,61) | List(47,19,61) | Correct. | Scala |
if x = 84 then
print('info')
end | if x == 84 then
print('info')
end | Use ==. | Lua |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
WHERE status = '28' | WHERE status = 28 | Don't quote integer. | SQL |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
print 'hello' | print('hello') | print needs parentheses. | Python |
if a = 34: | if a == 34: | Use == for comparison. | Python |
def test
puts 'test'
end | def test
puts 'test'
end | Correct. | Ruby |
switch(val){{ case 47: break; }} | switch(val){{ case 47: break; default: break; }} | Add default case. | Java |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
$data = 2; if ($data = 2) {{}} | $data = 2; if ($data == 2) {{}} | Use ==. | PHP |
test | test() | Add parentheses. | Swift |
<entry name='message'/> | <entry name="message"/> | Double quotes. | XML |
function compute() {{ echo 'data'; }} | function compute() {{ echo 'data'; }} | Correct. | PHP |
let s = String::from("data"); let ref=&s; s.push_str("!"); | let mut s = String::from("data"); let ref=&s; println!("{{}}", ref); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
if [ $y = 65 ]; then | if [ "$y" = 65 ]; then | Quote variable. | Shell |
my @arr = (27,69,39); | my @arr = (27,69,39); | Correct. | Perl |
if (val = 11) {{}} | if (val == 11) {{}} | Use ==. | Kotlin |
// comment | /* comment */ | Use /* */. | CSS |
if item = 88 {{}} | if item == 88 {{}} | Use ==. | Swift |
def compute():
print('output') | def compute():
print('output') | Indent function body. | Python |
var z int = 'hello' | var z string = 'hello' | Type mismatch. | Go |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
function foo() {{
return
{{key:'world'}}
}} | function foo() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
<user><desc>message</desc><age>58</age></user | <user><desc>message</desc><age>58</age></user> | Add closing >. | XML |
h1 {{ font-size:98px color:#fff; }} | h1 {{ font-size:98px; color:#fff; }} | Add semicolon. | CSS |
if (c = 1) {{}} | if (c == 1) {{}} | Use ==. | Java |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.