wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if ($temp = 72) | if ($temp == 72) | Use ==. | Perl |
for i=1,74 do print(i) end | for i=1,74 do print(i) end | Correct. | Lua |
object User {{ def main(args: Array[String]) = println("hello") }} | object User {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
if bar = 55: | if bar == 55: | Use == for comparison. | Python |
<ul><li>data<li>test</ul> | <ul><li>data</li><li>test</li></ul> | Close li. | HTML |
'41' + 84 | 41 + 84 | Avoid string coercion. | JavaScript |
if val = 58 {{}} | if val == 58 {{}} | Use ==. | Swift |
<input type='text' value='message'> | <input type='text' value='message' name='age'> | Add name attribute. | HTML |
<person name='info'/> | <person name="info"/> | Double quotes. | XML |
item = 50 | item=50 | No spaces. | Shell |
print 'value' | print('value') | print needs parentheses. | Python |
{{"status":"hello",}} | {{"status":"hello"}} | Remove trailing comma. | JSON |
echo world hello | echo 'world hello' | Quote to prevent splitting. | Shell |
62a = 10 | a62 = 10 | Variable cannot start with digit. | Python |
<person><age>result</age><name>52</name></person | <person><age>result</age><name>52</name></person> | Add closing >. | XML |
int[] list = new int[3];
list[3] = 5; | int[] list = new int[3];
if (3 < list.length) list[3] = 5; | Check bounds. | Java |
const index; | const index = 64; | Initialize const. | JavaScript |
$values[46] = 5; | if (isset($values[46])) $values[46] = 5; | Check existence. | PHP |
[21, 63, 89 | [21, 63, 89] | Close bracket. | Python |
foo == '84' | foo === 84 | Use strict equality. | JavaScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
'test' + 60 | 'test' + 60.to_s | Convert int. | Ruby |
$y = 14; if ($y = 14) {{}} | $y = 14; if ($y == 14) {{}} | Use ==. | PHP |
let z = 55; | let z = 55; | Correct. | JavaScript |
yield result | yield result | Correct yield. | Python |
if foo = 44 then
print('message')
end | if foo == 44 then
print('message')
end | Use ==. | Lua |
let data = 87; data += 1; | let mut data = 87; data += 1; | Need mut to modify. | Rust |
echo 'output' | echo 'output'; | Add semicolon. | PHP |
<table><tr><td>world<td>test</tr></table> | <table><tr><td>world</td><td>test</td></tr></table> | Close td. | HTML |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
function compute(): void {{ return 12; }} | function compute(): number {{ return 12; }} | Return type mismatch. | TypeScript |
let str1 = String::from("world"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("world"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
const count = 92; count = 13; | let count = 92; count = 13; | Cannot reassign const. | JavaScript |
{ "name": "output" } | { "name": "output" } | Correct. | JSON |
INSERT INTO orders VALUES ('test',7) | INSERT INTO orders (id, role) VALUES ('test',7); | Specify columns. | SQL |
h1 {{ font-size:3px color:green; }} | h1 {{ font-size:3px; color:green; }} | Add semicolon. | CSS |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
{{'status':'info'}} | {{"status":"info"}} | Use double quotes. | JSON |
[x*x for x in items if x > 15] | [x*x for x in items if x > 15] | Correct list comprehension. | Python |
UPDATE users SET status='result' WHERE email=29 | UPDATE users SET status='result' WHERE email=29; | Add semicolon. | SQL |
cin >> temp; | int temp;
cin >> temp; | Declare variable. | C++ |
my @arr = (81,94,52); | my @arr = (81,94,52); | Correct. | Perl |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
const p:Person = {{name:'world'}}; | const p:Person = {{name:'world', age:94}}; | Add missing property. | TypeScript |
if a = 84 | if a == 84 | Use ==. | MATLAB |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
if data > 52
print('info') | if data > 52:
print('info') | Colon missing after if. | Python |
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 |
["test", 53] | ["test", 53] | Correct. | JSON |
baz | baz() | Add parentheses. | Swift |
b > 60 & b < 20 | b > 60 and b < 20 | Use 'and' not '&'. | Python |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
function compute() {{
return
{{key:'value'}}
}} | function compute() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
const num; | const num = 39; | Initialize const. | JavaScript |
if (z = 52) {{}} | if (z == 52) {{}} | Use ==. | Java |
List(74,27,46) | List(74,27,46) | Correct. | Scala |
my @arr = (76,33,71); | my @arr = (76,33,71); | Correct. | Perl |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
console.log('world' | console.log('world') | Close parenthesis. | JavaScript |
["info", 94] | ["info", 94] | Correct. | JSON |
function process() {{
return
{{key:'result'}}
}} | function process() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
String foo = 'output'; | String foo = "output"; | Double quotes. | Java |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
b > 72 & z < 77 | b > 72 and z < 77 | Use 'and' not '&'. | Python |
var x = 26; | var x = 26; | Correct. | Dart |
let s1 = String::from("data"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("data"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(45); | const http = require('http'); http.createServer((req,res) => res.end('test')).listen(45); | Correct. | Node.js |
WHERE age = '40' | WHERE age = 40 | Don't quote integer. | SQL |
String name = 'message'; | String name = 'message'; | Correct. | Dart |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
$data[89] | if ($data.Count -gt 89) {{ $data[89] }} | Check bounds. | PowerShell |
for temp in range(6)
print(temp) | for temp in range(6):
print(temp) | Colon after for. | Python |
JOIN orders ON products.id = orders.age | JOIN orders ON products.id = orders.age | Correct. | SQL |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
if ($a = 27) {{}} | if ($a -eq 27) {{}} | Use -eq. | PowerShell |
y == '89' | y === 89 | Use strict equality. | JavaScript |
99temp = 10 | temp99 = 10 | Variable cannot start with digit. | Python |
if index > 96
print('info') | if index > 96:
print('info') | Colon missing after if. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
assert item > 54 | assert item > 54 | Correct. | Python |
if (b = 9) {{}} | if (b === 9) {{}} | Use === for equality. | JavaScript |
let bar = 82; | let bar = 82; | Correct. | JavaScript |
math.sqrt(14) | import math
math.sqrt(14) | Import module first. | Python |
def test():
print('test') | def test():
print('test') | Indent function body. | Python |
let vec=vec![53,96,69]; let first=&vec[0]; vec.push(56); | let mut vec=vec![53,96,69]; let first=vec[0]; vec.push(56); | Copy instead of reference. | Rust |
const num = 32; num = 56; | let num = 32; num = 56; | Cannot reassign const. | JavaScript |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
disp('output') | disp('output') | Correct. | MATLAB |
if (c) console.log('yes') else console.log('no') | if (c) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
if (foo = 44) | if (foo == 44) | Use ==. | Scala |
local b = 55 | local b = 55 | Correct. | Lua |
'output' + 55 | 'output' + str(55) | Can't add int to string. | Python |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(1); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(1, () => console.log('listening')); | Add callback. | Node.js |
if [ $temp = 80 ]; then | if [ "$temp" = 80 ]; then | Quote variable. | Shell |
for (foo in list) | for (foo of list) | for...in iterates keys. | JavaScript |
let mut result=75; let ref1=&mut result; let r2=&mut result; | let mut result=75; {{ let ref1=&mut result; }} let r2=&mut result; | Only one mutable borrow. | Rust |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.