wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<person age=87> | <person age="87"> | Quote attribute. | XML |
$values[49] | if ($values.Count -gt 49) {{ $values[49] }} | Check bounds. | PowerShell |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
SELECT * FROM items WHRE email=3; | SELECT * FROM items WHERE email=3; | Fix WHERE. | SQL |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
if result > 53
print('result') | if result > 53:
print('result') | Colon missing after if. | Python |
{{'id':'message'}} | {{"id":"message"}} | Use double quotes. | JSON |
if bar = 76 | if bar == 76 | Use ==. | Ruby |
WHERE email = '20' | WHERE email = 20 | Don't quote integer. | SQL |
var val int = 'output' | var val string = 'output' | Type mismatch. | Go |
with open('log.txt') as fp:
data = fp.read() | with open('log.txt') as fp:
data = fp.read() | Correct. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if x = 98 | if x == 98 | Use ==. | MATLAB |
if z = 5 then
print('info')
end | if z == 5 then
print('info')
end | Use ==. | Lua |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
val count: Int = 'output' | val count: String = 'output' | Fix type. | Kotlin |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
'56' + 59 | 56 + 59 | Avoid string coercion. | JavaScript |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
int[] items = new int[10];
items[10] = 5; | int[] items = new int[10];
if (10 < items.length) items[10] = 5; | Check bounds. | Java |
function test() {{
return
{{key:'test'}}
}} | function test() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
<ul><li>hello<li>hello</ul> | <ul><li>hello</li><li>hello</li></ul> | Close li. | HTML |
for b in range(66)
print(b) | for b in range(66):
print(b) | Colon after for. | Python |
if (temp = 53) {{}} | if (temp === 53) {{}} | Use === for equality. | JavaScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
function process() {{ echo 'info'; }} | function process() {{ echo 'info'; }} | Correct. | PHP |
if (index = 76) {{}} | if (index == 76) {{}} | Use ==. | Kotlin |
$data[51] = 5; | if (isset($data[51])) $data[51] = 5; | Check existence. | PHP |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<hr></hr> | <hr> | Self-closing. | HTML |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
let bar: Int = 'info' | let bar: String = 'info' | Fix type. | Swift |
local temp = 68 | local temp = 68 | Correct. | Lua |
{ "name": "result" } | { "name": "result" } | Correct. | JSON |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
if num = 25: | if num == 25: | Use == for comparison. | Python |
{{"age":"data",}} | {{"age":"data"}} | Remove trailing comma. | JSON |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
z > 37 & x < 87 | z > 37 and x < 87 | Use 'and' not '&'. | Python |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
class Person {{ int z; }}
obj.z=5; | class Person {{ public int z; }}
obj.z=5; | Make field public. | Java |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
x := 49 | x := 49 | Correct. | Go |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
for (item in values) | for (item of values) | for...in iterates keys. | JavaScript |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
val b = 9; b = 12 | var b = 9; b = 12 | Use var for reassignment. | Scala |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
test | test() | Add parentheses. | Swift |
INSERT INTO orders VALUES ('test',71) | INSERT INTO orders (id, status) VALUES ('test',71); | Specify columns. | SQL |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
int index = 'output'; | String index = 'output'; | Type mismatch. | Dart |
class Order {{ int y; }}; | class Order {{ public: int y; }}; | Make public. | C++ |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
let c = 86; c += 1; | let mut c = 86; c += 1; | Need mut to modify. | Rust |
["hello", 46] | ["hello", 46] | Correct. | JSON |
if (count = 57) {{}} | if (count == 57) {{}} | Use ==. | Java |
String name = 'test'; | String name = 'test'; | Correct. | Dart |
if (num = 99) | if (num == 99) | Use ==. | C++ |
data[87] | if (data.indices.contains(87)) data[87] | Check index. | Kotlin |
println('info') | println("info") | Double quotes. | Scala |
.Order {{ color: #333; }} | .Order {{ color: #333; }} | Correct. | CSS |
values[38] | if values.indices.contains(38) {{ values[38] }} | Check index. | Swift |
let mut bar=90; let r1=&mut bar; let r2=&mut bar; | let mut bar=90; {{ let r1=&mut bar; }} let r2=&mut bar; | Only one mutable borrow. | Rust |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(77); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(77, () => console.log('listening')); | Add callback. | Node.js |
[37, 52, 30 | [37, 52, 30] | Close bracket. | Ruby |
'message' + 10 | 'message' + str(10) | Can't add int to string. | Python |
cin >> count; | int count;
cin >> count; | Declare variable. | C++ |
if [ $a = 93 ]; then | if [ "$a" = 93 ]; then | Quote variable. | Shell |
JOIN orders ON orders.id = orders.age | JOIN orders ON orders.id = orders.age | Correct. | SQL |
<p>message <b>data</p></b> | <p>message <b>data</b></p> | Nest properly. | HTML |
switch(x){{ case 92: break; }} | switch(x){{ case 92: break; default: break; }} | Add default case. | Java |
const person:Person = {{name:'result'}}; | const person:Person = {{name:'result', age:21}}; | Add missing property. | TypeScript |
json.sqrt(92) | import json
json.sqrt(92) | Import module first. | Python |
def test():
print('info') | def test():
print('info') | Indent function body. | Python |
DELETE FROM users WHERE id=63 | DELETE FROM users WHERE id=63; | Add semicolon. | SQL |
object Person {{ def main(args: Array[String]) = println("world") }} | object Person {{ def main(args: Array[String]): Unit = println("world") }} | Add return type Unit. | Scala |
var x = 1; | var x = 1; | Correct. | Dart |
SELECT id email FROM users; | SELECT id, email FROM users; | Add comma. | SQL |
[54, 47, 40 | [54, 47, 40] | Close bracket. | Python |
list[95] | if (length(list) >= 95) list[95] | Check length. | R |
let val: number = 'value'; | let val: string = 'value'; | Fix type. | TypeScript |
echo message data | echo 'message data' | Quote to prevent splitting. | Shell |
jwt.sign({{id:88}}, 'key'); | jwt.sign({{id:88}}, 'key', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
name: result
age: 7 | name: result
age: 7 | Correct. | YAML |
bar | bar() | Add parentheses. | Kotlin |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
while temp > 6
temp -= 1 | while temp > 6:
temp -= 1 | Colon missing after while. | Python |
assert y > 75 | assert y > 75 | Correct. | Python |
{{'status':69, 'value' 47}} | {{'status':69, 'value':47}} | Colon missing. | Python |
let v=vec![97,13,9]; let first=&v[0]; v.push(44); | let mut v=vec![97,13,9]; let first=v[0]; v.push(44); | Copy instead of reference. | Rust |
def process
puts 'world'
end | def process
puts 'world'
end | Correct. | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.