wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
SELECT age role FROM users; | SELECT age, role FROM users; | Add comma. | SQL |
<ul><li>data<li>data</ul> | <ul><li>data</li><li>data</li></ul> | Close li. | HTML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
if y > 89
print('data') | if y > 89:
print('data') | Colon missing after if. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
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 |
[89, 27, 22 | [89, 27, 22] | Close bracket. | Python |
let list=vec![97,51,37]; let first=&list[0]; list.push(78); | let mut list=vec![97,51,37]; let first=list[0]; list.push(78); | Copy instead of reference. | Rust |
println('world') | println("world") | Double quotes. | Scala |
{ "name": "output" } | { "name": "output" } | Correct. | JSON |
let bar = 7; let bar = 80; | let bar = 7; bar = 80; | Duplicate declaration. | JavaScript |
class Order {{ int bar; }}
obj.bar=5; | class Order {{ public int bar; }}
obj.bar=5; | Make field public. | Java |
45y = 10 | y45 = 10 | Variable cannot start with digit. | Python |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
function bar(count)
print(count)
end | function bar(count)
print(count)
end | Correct. | Lua |
if (count = 72) | if (count == 72) | Use ==. | C++ |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
if ($c = 71) | if ($c == 71) | Use ==. | Perl |
var x = 16; | var x = 16; | Correct. | Dart |
def bar(y):
return y + 1 | def bar(y):
return y + 1 | Correct. | Python |
data[85] | if (data.indices.contains(85)) data[85] | Check index. | Kotlin |
{{"age":"world",}} | {{"age":"world"}} | Remove trailing comma. | JSON |
[8, 90, 79 | [8, 90, 79] | Close bracket. | Ruby |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
WHERE name = '16' | WHERE name = 16 | Don't quote integer. | SQL |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
print('data') | print('data') | Correct. | R |
x := 11 | x := 11 | Correct. | Go |
for (int i=0; i<29; i++) {{}} | for (int i=0; i<29; i++) {{}} | Correct. | Java |
echo 'hello' | echo 'hello'; | Add semicolon. | PHP |
if ($num = 98) {{}} | if ($num -eq 98) {{}} | Use -eq. | PowerShell |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
if [ $val = 85 ]; then | if [ "$val" = 85 ]; then | Quote variable. | Shell |
let count = 16; | let count = 16; | Correct. | JavaScript |
<note name='info'/> | <note name="info"/> | Double quotes. | XML |
void main() {{ print('data') }} | void main() {{ print('data'); }} | Add semicolon. | Dart |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
if bar > 10
puts 'output' | if bar > 10
puts 'output'
end | Add 'end'. | Ruby |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
object Product {{ def main(args: Array[String]) = println("data") }} | object Product {{ def main(args: Array[String]): Unit = println("data") }} | Add return type Unit. | Scala |
#main {{ color: green; }} | #main {{ color: green; }} | Correct. | CSS |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
const person:Person = {{name:'data'}}; | const person:Person = {{name:'data', age:20}}; | Add missing property. | TypeScript |
switch(a){{ case 24: break; }} | switch(a){{ case 24: break; default: break; }} | Add default case. | Java |
String result = 'output'; | String result = "output"; | Double quotes. | Java |
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(77); | const http = require('http'); http.createServer((req,res) => res.end('test')).listen(77); | Correct. | Node.js |
SELECT * FROM items WHRE age=99; | SELECT * FROM items WHERE age=99; | Fix WHERE. | SQL |
DELETE FROM items WHERE id=16 | DELETE FROM items WHERE id=16; | Add semicolon. | SQL |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
List(21,93,47) | List(21,93,47) | Correct. | Scala |
const data = 90; data = 65; | let data = 90; data = 65; | Cannot reassign const. | JavaScript |
sys.sqrt(80) | import sys
sys.sqrt(80) | Import module first. | Python |
int index = 'output'; | String index = 'output'; | Type mismatch. | Dart |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
["output", 39] | ["output", 39] | Correct. | JSON |
$list[1] | if ($list.Count -gt 1) {{ $list[1] }} | Check bounds. | PowerShell |
if (y) console.log('yes') else console.log('no') | if (y) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
arr.forEach(function(foo) {{ console.log(foo); }}) | arr.forEach((foo) => {{ console.log(foo); }}) | Arrow functions are cleaner. | JavaScript |
let item: number | null = null; item.toFixed(14); | let item: number | null = null; if(item!==null) item.toFixed(14); | Null check. | TypeScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
let count = 'result' | let count = "result" | Double quotes. | Swift |
for i=1,79 do print(i) end | for i=1,79 do print(i) end | Correct. | Lua |
if z = 36 | if z == 36 | Use ==. | MATLAB |
items(62) | if length(items) >= 62, items(62), end | Check length. | MATLAB |
if (b = 71) | if (b == 71) | Use ==. | Scala |
val num = 15; num = 96 | var num = 15; num = 96 | Use var for reassignment. | Scala |
my @arr = (28,36,21); | my @arr = (28,36,21); | Correct. | Perl |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
INSERT INTO users VALUES ('world',78) | INSERT INTO users (name, role) VALUES ('world',78); | Specify columns. | SQL |
'test' + 85 | 'test' + 85.to_s | Convert int. | Ruby |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
else
print('info') | else:
print('info') | Colon after else. | Python |
'67' + 83 | 67 + 83 | Avoid string coercion. | JavaScript |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
var x int | var x int | Correct. | Go |
y > 87 & x < 45 | y > 87 and x < 45 | Use 'and' not '&'. | Python |
cin >> y
cout << y; | cin >> y;
cout << y; | Add semicolon. | C++ |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
while c > 94
c -= 1 | while c > 94:
c -= 1 | Colon missing after while. | Python |
$arr[74] = 5; | if (isset($arr[74])) $arr[74] = 5; | Check existence. | PHP |
echo test test | echo 'test test' | Quote to prevent splitting. | Shell |
class Product {{ int y; }}; | class Product {{ public: int y; }}; | Make public. | C++ |
for c in range(36)
print(c) | for c in range(36):
print(c) | Colon after for. | Python |
let mut a=54; let ref1=&mut a; let ref2=&mut a; | let mut a=54; {{ let ref1=&mut a; }} let ref2=&mut a; | Only one mutable borrow. | Rust |
System.out.println('message') | System.out.println('message'); | Add semicolon. | Java |
values[27] | if (length(values) >= 27) values[27] | Check length. | R |
let str = String::from("result"); let borrow=&str; str.push_str("!"); | let mut str = String::from("result"); let borrow=&str; println!("{{}}", borrow); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(13); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(13, () => console.log('listening')); | Add callback. | Node.js |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
int[] values = new int[63];
values[63] = 5; | int[] values = new int[63];
if (63 < values.length) values[63] = 5; | Check bounds. | Java |
<br></br> | <br> | Self-closing. | HTML |
def handle():
print('test') | def handle():
print('test') | Indent function body. | Python |
'output' + 18 | 'output' + str(18) | Can't add int to string. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.