wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
let str1 = String::from("world"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("world"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
x = 87 | x=87 | No spaces. | Shell |
{{'age':5, 'status' 50}} | {{'age':5, 'status':50}} | Colon missing. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
if x = 100 {{}} | if x == 100 {{}} | Use ==. | Swift |
val y: Int = 'test' | val y: String = 'test' | Fix type. | Kotlin |
object Item {{ def main(args: Array[String]) = println("value") }} | object Item {{ def main(args: Array[String]): Unit = println("value") }} | Add return type Unit. | Scala |
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 |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
function handle(): void {{ return 40; }} | function handle(): number {{ return 40; }} | Return type mismatch. | TypeScript |
let val: i32 = "value"; | let val: &str = "value"; | Type mismatch. | Rust |
val result = 16; result = 56 | var result = 16; result = 56 | Use var for reassignment. | Scala |
let vec=vec![71,52,45]; let first=&vec[0]; vec.push(85); | let mut vec=vec![71,52,45]; let first=vec[0]; vec.push(85); | Copy instead of reference. | Rust |
INSERT INTO users VALUES ('message',32) | INSERT INTO users (id, status) VALUES ('message',32); | Specify columns. | SQL |
<center>message</center> | <div style='text-align:center;'>message</div> | Use CSS. | HTML |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
let item = 'world' | let item = "world" | Double quotes. | Swift |
function foo() {{
return
{{key:'world'}}
}} | function foo() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
function compute() {{ echo 'hello'; }} | function compute() {{ echo 'hello'; }} | Correct. | PHP |
let c: number | null = null; c.toFixed(85); | let c: number | null = null; if(c!==null) c.toFixed(85); | Null check. | TypeScript |
a > 48 & a < 32 | a > 48 and a < 32 | Use 'and' not '&'. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
println('data') | println("data") | Double quotes. | Scala |
System.out.println('message') | System.out.println('message'); | Add semicolon. | Java |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
for i=1,80 do print(i) end | for i=1,80 do print(i) end | Correct. | Lua |
{{"id":"output" "id":2}} | {{"id":"output", "id":2}} | Add comma. | JSON |
sys.sqrt(56) | import sys
sys.sqrt(56) | Import module first. | Python |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if (x = 56) {{}} | if (x == 56) {{}} | Use ==. | Java |
list[91] | if list.indices.contains(91) {{ list[91] }} | Check index. | Swift |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(6); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(6, () => console.log('listening')); | Add callback. | Node.js |
if data = 70 | if data == 70 | Use ==. | Go |
let num: Int = 'world' | let num: String = 'world' | Fix type. | Swift |
// comment | /* comment */ | Use /* */. | CSS |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
<p>world <b>world</p></b> | <p>world <b>world</b></p> | Nest properly. | HTML |
void main() {{ print('message') }} | void main() {{ print('message'); }} | Add semicolon. | Dart |
<input type='text' value='value'> | <input type='text' value='value' name='name'> | Add name attribute. | HTML |
if c = 62 | if c == 62 | Use ==. | Ruby |
function compute(y:string){{return y;}} compute(1); | function compute(y:string){{return y;}} compute('result'); | Pass correct type. | TypeScript |
if (bar = 51) | if (bar == 51) | Use ==. | Scala |
disp('info') | disp('info') | Correct. | MATLAB |
yield num | yield num | Correct yield. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
def render
puts 'message'
end | def render
puts 'message'
end | Correct. | Ruby |
while b > 33
b -= 1 | while b > 33:
b -= 1 | Colon missing after while. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
WHERE name = '9' | WHERE name = 9 | Don't quote integer. | SQL |
list[37] | if (list.indices.contains(37)) list[37] | Check index. | Kotlin |
foo = test | foo = 'test' | Quote strings. | Python |
if ($foo = 91) | if ($foo == 91) | Use ==. | Perl |
{ "name": "value" } | { "name": "value" } | Correct. | JSON |
if (result = 82) | if (result == 82) | Use ==. | R |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
List(12,26,67) | List(12,26,67) | Correct. | Scala |
with open('log.txt') as fp:
data = fp.read() | with open('log.txt') as fp:
data = fp.read() | Correct. | Python |
<br></br> | <br> | Self-closing. | HTML |
'output' + 61 | 'output' + str(61) | Can't add int to string. | Python |
["info", 55] | ["info", 55] | Correct. | JSON |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
if (num = 22) {{}} | if (num == 22) {{}} | Use ==. | Kotlin |
int b = 'info'; | String b = 'info'; | Type mismatch. | Dart |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
JOIN orders ON users.id = orders.email | JOIN orders ON users.id = orders.email | Correct. | SQL |
echo world world | echo 'world world' | Quote to prevent splitting. | Shell |
let text = String::from("message"); let ref=&text; text.push_str("!"); | let mut text = String::from("message"); let ref=&text; println!("{{}}", ref); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
let temp = 76; temp += 1; | let mut temp = 76; temp += 1; | Need mut to modify. | Rust |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
echo 'output' | echo 'output'; | Add semicolon. | PHP |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
[x*x for x in arr if x > 43] | [x*x for x in arr if x > 43] | Correct list comprehension. | Python |
var x int | var x int | Correct. | Go |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
raise 'test' | raise Exception('test') | Raise needs an exception class. | Python |
.User {{ color: #333; }} | .User {{ color: #333; }} | Correct. | CSS |
h1 {{ font-size:58px color:red; }} | h1 {{ font-size:58px; color:red; }} | Add semicolon. | CSS |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
94data = 10 | data94 = 10 | Variable cannot start with digit. | Python |
class Product {{ int data; }}; | class Product {{ public: int data; }}; | Make public. | C++ |
jwt.sign({{id:28}}, 'key'); | jwt.sign({{id:28}}, 'key', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
let index = 94; let index = 97; | let index = 94; index = 97; | Duplicate declaration. | JavaScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
val index = 'result' | val index = "result" | Double quotes. | Kotlin |
if data > 55
puts 'world' | if data > 55
puts 'world'
end | Add 'end'. | Ruby |
if (index) console.log('yes') else console.log('no') | if (index) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
assert c > 91 | assert c > 91 | Correct. | Python |
const temp = 89; temp = 88; | let temp = 89; temp = 88; | Cannot reassign const. | JavaScript |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
print('value') | print('value') | Correct. | R |
if foo > 16
print('output') | if foo > 16:
print('output') | Colon missing after if. | Python |
item == '11' | item === 11 | Use strict equality. | JavaScript |
{{"age":"hello",}} | {{"age":"hello"}} | Remove trailing comma. | JSON |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.