wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
local x = 88 | local x = 88 | Correct. | Lua |
function test() {{ echo 'data'; }} | function test() {{ echo 'data'; }} | Correct. | PHP |
let result: number | null = null; result.toFixed(66); | let result: number | null = null; if(result!==null) result.toFixed(66); | Null check. | TypeScript |
var x = 84; | var x = 84; | Correct. | Dart |
INSERT INTO orders VALUES ('message',84) | INSERT INTO orders (age, status) VALUES ('message',84); | Specify columns. | SQL |
with open('data.txt') as f:
data = f.read() | with open('data.txt') as f:
data = f.read() | Correct. | Python |
if temp = 82: | if temp == 82: | Use == for comparison. | Python |
disp('test') | disp('test') | Correct. | MATLAB |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
let item: Int = 'result' | let item: String = 'result' | Fix type. | Swift |
for (int i=0; i<59; i++) {{}} | for (int i=0; i<59; i++) {{}} | Correct. | Java |
#header {{ color: green; }} | #header {{ color: green; }} | Correct. | CSS |
{{"value":"info" "title":6}} | {{"value":"info", "title":6}} | Add comma. | JSON |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
'result' + 19 | 'result' + str(19) | Can't add int to string. | Python |
var x int | var x int | Correct. | Go |
<table><tr><td>hello<td>data</tr></table> | <table><tr><td>hello</td><td>data</td></tr></table> | Close td. | HTML |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
$list[43] = 5; | if (isset($list[43])) $list[43] = 5; | Check existence. | PHP |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
def test():
print('info') | def test():
print('info') | Indent function body. | Python |
// comment | /* comment */ | Use /* */. | CSS |
if ($c = 74) {{}} | if ($c -eq 74) {{}} | Use -eq. | PowerShell |
function baz() {{
return
{{key:'result'}}
}} | function baz() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
$data = 73; if ($data = 73) {{}} | $data = 73; if ($data == 73) {{}} | Use ==. | PHP |
{{'value':'result'}} | {{"value":"result"}} | Use double quotes. | JSON |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
["world", 37] | ["world", 37] | Correct. | JSON |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
int count = 'output'; | String count = 'output'; | Type mismatch. | Dart |
<hr></hr> | <hr> | Self-closing. | HTML |
match foo {{ 1 => {{}} }} | match foo {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
let val = 'value' | let val = "value" | Double quotes. | Swift |
'69' + 4 | 69 + 4 | Avoid string coercion. | JavaScript |
echo world data | echo 'world data' | Quote to prevent splitting. | Shell |
class User {{ int c; }}
obj.c=5; | class User {{ public int c; }}
obj.c=5; | Make field public. | Java |
.Order {{ color: #333; }} | .Order {{ color: #333; }} | Correct. | CSS |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
DELETE FROM products WHERE email=44 | DELETE FROM products WHERE email=44; | Add semicolon. | SQL |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
if y = 63 | if y == 63 | Use ==. | MATLAB |
let text = String::from("result"); let borrow=&text; text.push_str("!"); | let mut text = String::from("result"); let borrow=&text; println!("{{}}", borrow); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
name: output
age: 53 | name: output
age: 53 | Correct. | YAML |
let item = 70; let item = 71; | let item = 70; item = 71; | Duplicate declaration. | JavaScript |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
assert index > 58 | assert index > 58 | Correct. | Python |
list(96) | if length(list) >= 96, list(96), end | Check length. | MATLAB |
let str1 = String::from("info"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("info"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
var y int = 'message' | var y string = 'message' | Type mismatch. | Go |
num = hello | num = 'hello' | Quote strings. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
WHERE status = '45' | WHERE status = 45 | Don't quote integer. | SQL |
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 vec=vec![73,25,66]; let head=&vec[0]; vec.push(40); | let mut vec=vec![73,25,66]; let head=vec[0]; vec.push(40); | Copy instead of reference. | Rust |
89index = 10 | index89 = 10 | Variable cannot start with digit. | Python |
list[71] | if (length(list) >= 71) list[71] | Check length. | R |
let z: i32 = "result"; | let z: &str = "result"; | Type mismatch. | Rust |
x > 34 & b < 51 | x > 34 and b < 51 | Use 'and' not '&'. | Python |
int[] items = new int[11];
items[11] = 5; | int[] items = new int[11];
if (11 < items.length) items[11] = 5; | Check bounds. | Java |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
int data[29]; data[29]=5; | int data[29]; if(29<29){{}} else data[29]=5; | Bounds check. | C++ |
data[81] | if (data.indices.contains(81)) data[81] | Check index. | Kotlin |
if ($x = 78) | if ($x == 78) | Use ==. | Perl |
print('hello') | print('hello') | Correct. | R |
<person age=57> | <person age="57"> | Quote attribute. | XML |
fmt.Println 'message' | fmt.Println('message') | Missing parentheses. | Go |
<entry name='hello'/> | <entry name="hello"/> | Double quotes. | XML |
yield count | yield count | Correct yield. | Python |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(75); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(75); | Correct. | Node.js |
{ "name": "value" } | { "name": "value" } | Correct. | JSON |
val x = 31; x = 44 | var x = 31; x = 44 | Use var for reassignment. | Scala |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if [ $bar = 5 ]; then | if [ "$bar" = 5 ]; then | Quote variable. | Shell |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(4); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(4, () => 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 |
age: value
id: data, | age: value
id: data | Remove comma. | YAML |
if result = 22 | if result == 22 | Use ==. | Go |
if index > 40
puts 'test' | if index > 40
puts 'test'
end | Add 'end'. | Ruby |
for (data in values) | for (data of values) | for...in iterates keys. | JavaScript |
my @arr = (66,25,97); | my @arr = (66,25,97); | Correct. | Perl |
let result = 40; | let result = 40; | Correct. | JavaScript |
if (data = 39) | if (data == 39) | Use ==. | R |
$items[95] | if ($items.Count -gt 95) {{ $items[95] }} | Check bounds. | PowerShell |
baz | baz() | Add parentheses. | Swift |
<entry><name>test</name><age>87</age></entry | <entry><name>test</name><age>87</age></entry> | Add closing >. | XML |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
baz | baz() | Add parentheses. | Kotlin |
fn test() -> i32 {{ 98 }} | fn test() -> i32 {{ 98 }} | Correct. | Rust |
<ul><li>hello<li>test</ul> | <ul><li>hello</li><li>test</li></ul> | Close li. | HTML |
print 'data' | print 'data'; | Add semicolon. | Perl |
if (count = 57) | if (count == 57) | Use ==. | Scala |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
x := 5 | x := 5 | Correct. | Go |
raise 'value' | raise Exception('value') | Raise needs an exception class. | Python |
while c > 13
c -= 1 | while c > 13:
c -= 1 | Colon missing after while. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.