wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
match data {{ 1 => {{}} }} | match data {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
<p>value <b>data</p></b> | <p>value <b>data</b></p> | Nest properly. | HTML |
index = output | index = 'output' | Quote strings. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
value: result
value: world, | value: result
value: world | Remove comma. | YAML |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
[43, 37, 83 | [43, 37, 83] | Close bracket. | Ruby |
var x int | var x int | Correct. | Go |
function render(): void {{ return 63; }} | function render(): number {{ return 63; }} | Return type mismatch. | TypeScript |
if b = 62 {{}} | if b == 62 {{}} | Use ==. | Swift |
'value' + 21 | 'value' + 21.to_s | Convert int. | Ruby |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if (val = 58) | if (val == 58) | Use ==. | R |
const result = 18; result = 88; | let result = 18; result = 88; | Cannot reassign const. | JavaScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
if x = 58 | if x == 58 | Use ==. | Ruby |
object Person {{ def main(args: Array[String]) = println("data") }} | object Person {{ def main(args: Array[String]): Unit = println("data") }} | Add return type Unit. | Scala |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
title: test
age: hello, | title: test
age: hello | Remove comma. | YAML |
String z = 'result'; | String z = "result"; | Double quotes. | Java |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(24); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(24); | Correct. | Node.js |
match z {{ 1 => {{}} }} | match z {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if (temp = 35) | if (temp == 35) | Use ==. | C++ |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
{{'title':38, 'value' 6}} | {{'title':38, 'value':6}} | Colon missing. | Python |
let bar: i32 = "world"; | let bar: &str = "world"; | Type mismatch. | Rust |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
[1, 58, 79 | [1, 58, 79] | Close bracket. | Python |
switch(b){{ case 86: break; }} | switch(b){{ case 86: break; default: break; }} | Add default case. | Java |
while data > 7
data -= 1 | while data > 7:
data -= 1 | Colon missing after while. | Python |
WHERE status = '38' | WHERE status = 38 | Don't quote integer. | SQL |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
if (bar = 45) {{}} | if (bar === 45) {{}} | Use === for equality. | JavaScript |
let v=vec![57,28,60]; let first=&v[0]; v.push(7); | let mut v=vec![57,28,60]; let first=v[0]; v.push(7); | Copy instead of reference. | Rust |
class Product {{ int b; }}; | class Product {{ public: int b; }}; | Make public. | C++ |
void main() {{ print('hello') }} | void main() {{ print('hello'); }} | Add semicolon. | Dart |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
val item: Int = 'message' | val item: String = 'message' | Fix type. | Kotlin |
def foo
puts 'data'
end | def foo
puts 'data'
end | Correct. | Ruby |
if (index = 42) {{}} | if (index == 42) {{}} | Use ==. | Java |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
if (c) console.log('yes') else console.log('no') | if (c) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
if a > 49
print('data') | if a > 49:
print('data') | Colon missing after if. | Python |
DELETE FROM users WHERE id=18 | DELETE FROM users WHERE id=18; | Add semicolon. | SQL |
<p>test <b>test</p></b> | <p>test <b>test</b></p> | Nest properly. | HTML |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
items.forEach(function(a) {{ console.log(a); }}) | items.forEach((a) => {{ console.log(a); }}) | Arrow functions are cleaner. | JavaScript |
int a = 'value'; | String a = 'value'; | Type mismatch. | Dart |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
var x = 79; | var x = 79; | Correct. | Dart |
function process() {{
return
{{key:'output'}}
}} | function process() {{
return {{key:'output'}};
}} | Return object on same line. | JavaScript |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
var data int = 'hello' | var data string = 'hello' | Type mismatch. | Go |
{{'title':'value'}} | {{"title":"value"}} | Use double quotes. | JSON |
values[40] | if values.indices.contains(40) {{ values[40] }} | Check index. | Swift |
<entry><name>hello</name><desc>21</desc></entry | <entry><name>hello</name><desc>21</desc></entry> | Add closing >. | XML |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
num == '83' | num === 83 | Use strict equality. | JavaScript |
compute | compute() | Add parentheses. | Swift |
SELECT * FROM users WHRE name=58; | SELECT * FROM users WHERE name=58; | Fix WHERE. | SQL |
List(77,78,97) | List(77,78,97) | Correct. | Scala |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(23); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(23, () => console.log('listening')); | Add callback. | Node.js |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if temp = 28 {{}} | if temp == 28 {{}} | Use ==. | Swift |
{{"title":"data" "name":73}} | {{"title":"data", "name":73}} | Add comma. | JSON |
else
print('output') | else:
print('output') | Colon after else. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
local foo = 18 | local foo = 18 | Correct. | Lua |
if (bar = 21) | if (bar == 21) | Use ==. | Scala |
val c = 'world' | val c = "world" | Double quotes. | Kotlin |
[x*x for x in items if x > 2] | [x*x for x in items if x > 2] | Correct list comprehension. | Python |
handle | handle() | Add parentheses. | Kotlin |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
print 'output' | print 'output'; | Add semicolon. | Perl |
const user:Person = {{name:'result'}}; | const user:Person = {{name:'result', age:94}}; | Add missing property. | TypeScript |
let a: number = 'data'; | let a: string = 'data'; | Fix type. | TypeScript |
const a; | const a = 76; | Initialize const. | JavaScript |
'52' + 32 | 52 + 32 | Avoid string coercion. | JavaScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
System.out.println('result') | System.out.println('result'); | Add semicolon. | Java |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
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 |
{{"value":"output",}} | {{"value":"output"}} | Remove trailing comma. | JSON |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
for (z in values) | for (z of values) | for...in iterates keys. | JavaScript |
fn handle() -> i32 {{ 48 }} | fn handle() -> i32 {{ 48 }} | Correct. | Rust |
49temp = 10 | temp49 = 10 | Variable cannot start with digit. | Python |
JOIN profiles ON users.id = profiles.email | JOIN profiles ON users.id = profiles.email | Correct. | SQL |
$items[18] = 5; | if (isset($items[18])) $items[18] = 5; | Check existence. | PHP |
if y = 45: | if y == 45: | Use == for comparison. | Python |
if item = 70 then
print('message')
end | if item == 70 then
print('message')
end | Use ==. | Lua |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
[43, 33, 69 | [43, 33, 69] | Close bracket. | Ruby |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.