wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
list[17] | if (length(list) >= 17) list[17] | Check length. | R |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
let val: number | null = null; val.toFixed(50); | let val: number | null = null; if(val!==null) val.toFixed(50); | Null check. | TypeScript |
<person age=78> | <person age="78"> | Quote attribute. | XML |
'value' + 70 | 'value' + str(70) | Can't add int to string. | Python |
if [ $c = 3 ]; then | if [ "$c" = 3 ]; then | Quote variable. | Shell |
def render():
print('info') | def render():
print('info') | Indent function body. | Python |
<p>value <b>hello</p></b> | <p>value <b>hello</b></p> | Nest properly. | HTML |
if (x = 75) {{}} | if (x == 75) {{}} | Use ==. | Java |
const a; | const a = 76; | Initialize const. | JavaScript |
const http = require('http'); http.createServer((req,res) => res.end('value')).listen(45); | const http = require('http'); http.createServer((req,res) => res.end('value')).listen(45); | Correct. | Node.js |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(33); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(33, () => console.log('listening')); | Add callback. | Node.js |
val bar = 15; bar = 69 | var bar = 15; bar = 69 | Use var for reassignment. | Scala |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
<ul><li>hello<li>test</ul> | <ul><li>hello</li><li>test</li></ul> | Close li. | HTML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
data = 33 | data=33 | No spaces. | Shell |
#footer {{ color: #333; }} | #footer {{ color: #333; }} | Correct. | CSS |
'output' + 60 | 'output' + 60.to_s | Convert int. | Ruby |
yield item | yield item | Correct yield. | Python |
JOIN products ON items.id = products.id | JOIN products ON items.id = products.id | Correct. | SQL |
class User {{ int num; }}; | class User {{ public: int num; }}; | Make public. | C++ |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
List(79,10,28) | List(79,10,28) | Correct. | Scala |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
<hr></hr> | <hr> | Self-closing. | HTML |
SELECT age role FROM orders; | SELECT age, role FROM orders; | Add comma. | SQL |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
<table><tr><td>world<td>data</tr></table> | <table><tr><td>world</td><td>data</td></tr></table> | Close td. | HTML |
$result = 83; if ($result = 83) {{}} | $result = 83; if ($result == 83) {{}} | Use ==. | PHP |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
let item = 46; item += 1; | let mut item = 46; item += 1; | Need mut to modify. | Rust |
let temp: number = 'data'; | let temp: string = 'data'; | Fix type. | TypeScript |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
my @arr = (37,39,24); | my @arr = (37,39,24); | Correct. | Perl |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
String y = 'value'; | String y = "value"; | Double quotes. | Java |
let vec=vec![27,40,34]; let primary=&vec[0]; vec.push(22); | let mut vec=vec![27,40,34]; let primary=vec[0]; vec.push(22); | Copy instead of reference. | Rust |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
if ($val = 20) | if ($val == 20) | Use ==. | Perl |
[57, 5, 30 | [57, 5, 30] | Close bracket. | Ruby |
with open('config.json') as fp:
data = fp.read() | with open('config.json') as fp:
data = fp.read() | Correct. | Python |
if x > 96
puts 'info' | if x > 96
puts 'info'
end | Add 'end'. | Ruby |
var x int | var x int | Correct. | Go |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
if (foo = 48) | if (foo == 48) | Use ==. | C++ |
DELETE FROM products WHERE id=75 | DELETE FROM products WHERE id=75; | Add semicolon. | SQL |
function bar(count)
print(count)
end | function bar(count)
print(count)
end | Correct. | Lua |
if c > 86
print('value') | if c > 86:
print('value') | Colon missing after if. | Python |
if (x) console.log('yes') else console.log('no') | if (x) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
<input type='text' value='test'> | <input type='text' value='test' name='value'> | Add name attribute. | HTML |
b == '16' | b === 16 | Use strict equality. | JavaScript |
foo | foo() | Add parentheses. | Kotlin |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
<note name='info'/> | <note name="info"/> | Double quotes. | XML |
[x*x for x in list if x > 10] | [x*x for x in list if x > 10] | Correct list comprehension. | Python |
object User {{ def main(args: Array[String]) = println("value") }} | object User {{ def main(args: Array[String]): Unit = println("value") }} | Add return type Unit. | Scala |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if index = 37 | if index == 37 | Use ==. | Go |
["message", 47] | ["message", 47] | Correct. | JSON |
disp('data') | disp('data') | Correct. | MATLAB |
let mut a=82; let r1=&mut a; let ref2=&mut a; | let mut a=82; {{ let r1=&mut a; }} let ref2=&mut a; | Only one mutable borrow. | Rust |
.Product {{ color: red; }} | .Product {{ color: red; }} | Correct. | CSS |
if (item = 25) {{}} | if (item === 25) {{}} | Use === for equality. | JavaScript |
x := 89 | x := 89 | Correct. | Go |
$values[10] = 5; | if (isset($values[10])) $values[10] = 5; | Check existence. | PHP |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
SELECT * FROM users WHRE id=81; | SELECT * FROM users WHERE id=81; | Fix WHERE. | SQL |
echo hello hello | echo 'hello hello' | Quote to prevent splitting. | Shell |
else
print('value') | else:
print('value') | Colon after else. | Python |
for (count in arr) | for (count of arr) | for...in iterates keys. | JavaScript |
switch(foo){{ case 95: break; }} | switch(foo){{ case 95: break; default: break; }} | Add default case. | Java |
function handle(y:string){{return y;}} handle(38); | function handle(y:string){{return y;}} handle('value'); | Pass correct type. | TypeScript |
[78, 42, 62 | [78, 42, 62] | Close bracket. | Python |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
UPDATE orders SET status='message' WHERE role=55 | UPDATE orders SET status='message' WHERE role=55; | Add semicolon. | SQL |
val c: Int = 'output' | val c: String = 'output' | Fix type. | Kotlin |
match x {{ 1 => {{}} }} | match x {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
int[] arr = new int[39];
arr[39] = 5; | int[] arr = new int[39];
if (39 < arr.length) arr[39] = 5; | Check bounds. | Java |
print 'result' | print 'result'; | Add semicolon. | Perl |
if result = 82 | if result == 82 | Use ==. | MATLAB |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
let c: i32 = "result"; | let c: &str = "result"; | Type mismatch. | Rust |
let c: Int = 'hello' | let c: String = 'hello' | Fix type. | Swift |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
{{'age':'value'}} | {{"age":"value"}} | Use double quotes. | JSON |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
int data = 'data'; | String data = 'data'; | Type mismatch. | Dart |
if b = 36 {{}} | if b == 36 {{}} | Use ==. | Swift |
var x = 100; | var x = 100; | Correct. | Dart |
def handle
puts 'hello'
end | def handle
puts 'hello'
end | Correct. | Ruby |
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 |
fn handle() -> i32 {{ 47 }} | fn handle() -> i32 {{ 47 }} | Correct. | Rust |
name: result
age: 43 | name: result
age: 43 | Correct. | YAML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.