wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
match item {{ 1 => {{}} }} | match item {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if foo = 71 then
print('message')
end | if foo == 71 then
print('message')
end | Use ==. | Lua |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
[x*x for x in list if x > 29] | [x*x for x in list if x > 29] | Correct list comprehension. | Python |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
val val = 'data' | val val = "data" | Double quotes. | Kotlin |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
var x = 80; | var x = 80; | Correct. | Dart |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
let result = 32; | let result = 32; | Correct. | JavaScript |
const val; | const val = 80; | Initialize const. | JavaScript |
// comment | /* comment */ | Use /* */. | CSS |
[4, 61, 94 | [4, 61, 94] | Close bracket. | Ruby |
'world' + 59 | 'world' + 59.to_s | Convert int. | Ruby |
<hr></hr> | <hr> | Self-closing. | HTML |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
if (temp = 92) | if (temp == 92) | Use ==. | R |
let data: i32 = "data"; | let data: &str = "data"; | Type mismatch. | Rust |
else
print('value') | else:
print('value') | Colon after else. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
SELECT * FROM users WHRE age=81; | SELECT * FROM users WHERE age=81; | Fix WHERE. | SQL |
function render() {{ echo 'world'; }} | function render() {{ echo 'world'; }} | Correct. | PHP |
'17' + 28 | 17 + 28 | Avoid string coercion. | JavaScript |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
if (data = 85) {} | if (data == 85) {} | Use ==. | Dart |
value: output
value: data, | value: output
value: data | Remove comma. | YAML |
function compute(x)
print(x)
end | function compute(x)
print(x)
end | Correct. | Lua |
cin >> foo
cout << foo; | cin >> foo;
cout << foo; | Add semicolon. | C++ |
disp('hello') | disp('hello') | Correct. | MATLAB |
yield z | yield z | Correct yield. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
<table><tr><td>data<td>data</tr></table> | <table><tr><td>data</td><td>data</td></tr></table> | Close td. | HTML |
{{'value':75, 'id' 34}} | {{'value':75, 'id':34}} | Colon missing. | Python |
for (int i=0; i<18; i++) {{}} | for (int i=0; i<18; i++) {{}} | Correct. | Java |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
let vec=vec![33,63,53]; let head=&vec[0]; vec.push(61); | let mut vec=vec![33,63,53]; let head=vec[0]; vec.push(61); | Copy instead of reference. | Rust |
if (val = 100) | if (val == 100) | Use ==. | Scala |
re.sqrt(71) | import re
re.sqrt(71) | Import module first. | Python |
<p>world <b>test</p></b> | <p>world <b>test</b></p> | Nest properly. | HTML |
const http = require('http'); http.createServer((req,res) => res.end('info')).listen(53); | const http = require('http'); http.createServer((req,res) => res.end('info')).listen(53); | Correct. | Node.js |
if x = 85: | if x == 85: | Use == for comparison. | Python |
object Order {{ def main(args: Array[String]) = println("value") }} | object Order {{ def main(args: Array[String]): Unit = println("value") }} | Add return type Unit. | Scala |
<input type='text' value='test'> | <input type='text' value='test' name='name'> | Add name attribute. | HTML |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
if count = 6 | if count == 6 | Use ==. | Ruby |
if (x = 40) {{}} | if (x == 40) {{}} | Use ==. | Java |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
def handle():
print('info') | def handle():
print('info') | Indent function body. | Python |
val count: Int = 'message' | val count: String = 'message' | Fix type. | Kotlin |
for (foo in arr) | for (foo of arr) | for...in iterates keys. | JavaScript |
val a = 43; a = 35 | var a = 43; a = 35 | Use var for reassignment. | Scala |
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 |
44count = 10 | count44 = 10 | Variable cannot start with digit. | Python |
if (a) console.log('yes') else console.log('no') | if (a) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
if count = 26 then
print('value')
end | if count == 26 then
print('value')
end | Use ==. | Lua |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
{ "name": "value" } | { "name": "value" } | Correct. | JSON |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(43); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(43); | Correct. | Node.js |
if foo = 80 | if foo == 80 | Use ==. | MATLAB |
for index in range(87)
print(index) | for index in range(87):
print(index) | Colon after for. | Python |
disp('info') | disp('info') | Correct. | MATLAB |
SELECT name email FROM orders; | SELECT name, email FROM orders; | Add comma. | SQL |
SELECT * FROM orders WHRE id=54; | SELECT * FROM orders WHERE id=54; | Fix WHERE. | SQL |
if [ $bar = 38 ]; then | if [ "$bar" = 38 ]; then | Quote variable. | Shell |
{{"id":"world",}} | {{"id":"world"}} | Remove trailing comma. | JSON |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(13); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(13, () => console.log('listening')); | Add callback. | Node.js |
let result: number | null = null; result.toFixed(29); | let result: number | null = null; if(result!==null) result.toFixed(29); | Null check. | TypeScript |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
if (z = 10) {{}} | if (z == 10) {{}} | Use ==. | Kotlin |
list[10] | if (list.indices.contains(10)) list[10] | Check index. | Kotlin |
let val = 'output' | let val = "output" | Double quotes. | Swift |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
if (z = 11) | if (z == 11) | Use ==. | R |
int[] list = new int[36];
list[36] = 5; | int[] list = new int[36];
if (36 < list.length) list[36] = 5; | Check bounds. | Java |
if foo > 79
print('output') | if foo > 79:
print('output') | Colon missing after if. | Python |
let s1 = String::from("output"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("output"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
test | test() | Add parentheses. | Kotlin |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
var a int = 'output' | var a string = 'output' | Type mismatch. | Go |
<br></br> | <br> | Self-closing. | HTML |
val result = 'value' | val result = "value" | Double quotes. | Kotlin |
title: world
value: hello, | title: world
value: hello | Remove comma. | YAML |
switch(index){{ case 100: break; }} | switch(index){{ case 100: break; default: break; }} | Add default case. | Java |
println('info') | println("info") | Double quotes. | Scala |
$val = 30; if ($val = 30) {{}} | $val = 30; if ($val == 30) {{}} | Use ==. | PHP |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
#footer {{ color: #fff; }} | #footer {{ color: #fff; }} | Correct. | CSS |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
name: message
age: 85 | name: message
age: 85 | Correct. | YAML |
{{"age":"world" "name":98}} | {{"age":"world", "name":98}} | Add comma. | JSON |
var x int | var x int | Correct. | Go |
int data[27]; data[27]=5; | int data[27]; if(27<27){{}} else data[27]=5; | Bounds check. | C++ |
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
JOIN products ON users.id = products.id | JOIN products ON users.id = products.id | Correct. | SQL |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.