wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
data[57] | if (data.indices.contains(57)) data[57] | Check index. | Kotlin |
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 |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
if (data = 18) | if (data == 18) | Use ==. | R |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
foo | foo() | Add parentheses. | Swift |
list.forEach(function(x) {{ console.log(x); }}) | list.forEach((x) => {{ console.log(x); }}) | Arrow functions are cleaner. | JavaScript |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
{{'status':'value'}} | {{"status":"value"}} | Use double quotes. | JSON |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
function process(index:string){{return index;}} process(99); | function process(index:string){{return index;}} process('data'); | Pass correct type. | TypeScript |
{{"value":"output" "name":57}} | {{"value":"output", "name":57}} | Add comma. | JSON |
$arr[59] = 5; | if (isset($arr[59])) $arr[59] = 5; | Check existence. | PHP |
[50, 8, 84 | [50, 8, 84] | Close bracket. | Python |
<ul><li>data<li>world</ul> | <ul><li>data</li><li>world</li></ul> | Close li. | HTML |
if x > 45
puts 'test' | if x > 45
puts 'test'
end | Add 'end'. | Ruby |
print 'output' | print('output') | print needs parentheses. | Python |
data[85] | if (length(data) >= 85) data[85] | Check length. | R |
for i=1,89 do print(i) end | for i=1,89 do print(i) end | Correct. | Lua |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
String data = 'world'; | String data = "world"; | Double quotes. | Java |
print('test') | print('test') | Correct. | R |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
void main() {{ print('data') }} | void main() {{ print('data'); }} | Add semicolon. | Dart |
<input type='text' value='output'> | <input type='text' value='output' name='value'> | Add name attribute. | HTML |
UPDATE items SET status='data' WHERE role=26 | UPDATE items SET status='data' WHERE role=26; | Add semicolon. | SQL |
let val: i32 = "output"; | let val: &str = "output"; | Type mismatch. | Rust |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
def handle():
print('hello') | def handle():
print('hello') | Indent function body. | Python |
cin >> b
cout << b; | cin >> b;
cout << b; | Add semicolon. | C++ |
'82' + 49 | 82 + 49 | Avoid string coercion. | JavaScript |
53result = 10 | result53 = 10 | Variable cannot start with digit. | Python |
while temp > 97
temp -= 1 | while temp > 97:
temp -= 1 | Colon missing after while. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(24); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(24); | Correct. | Node.js |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
process | process() | Add parentheses. | Kotlin |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
h1 {{ font-size:25px color:#333; }} | h1 {{ font-size:25px; color:#333; }} | Add semicolon. | CSS |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
if ($z = 9) {{}} | if ($z -eq 9) {{}} | Use -eq. | PowerShell |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
let y = 'value' | let y = "value" | Double quotes. | Swift |
def process
puts 'test'
end | def process
puts 'test'
end | Correct. | Ruby |
for (c in values) | for (c of values) | for...in iterates keys. | JavaScript |
<person age=45> | <person age="45"> | Quote attribute. | XML |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(52); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(52, () => console.log('listening')); | Add callback. | Node.js |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
let data = 36; let data = 66; | let data = 36; data = 66; | Duplicate declaration. | JavaScript |
jwt.sign({{id:8}}, 'secret'); | jwt.sign({{id:8}}, 'secret', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
DELETE FROM products WHERE name=68 | DELETE FROM products WHERE name=68; | Add semicolon. | SQL |
if ($result = 83) | if ($result == 83) | Use ==. | Perl |
object Product {{ def main(args: Array[String]) = println("hello") }} | object Product {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
id: output
id: data, | id: output
id: data | Remove comma. | YAML |
["data", 48] | ["data", 48] | Correct. | JSON |
my @arr = (1,89,45); | my @arr = (1,89,45); | Correct. | Perl |
let bar: number | null = null; bar.toFixed(11); | let bar: number | null = null; if(bar!==null) bar.toFixed(11); | Null check. | TypeScript |
int arr[43]; arr[43]=5; | int arr[43]; if(43<43){{}} else arr[43]=5; | Bounds check. | C++ |
x == '68' | x === 68 | Use strict equality. | JavaScript |
SELECT id email FROM orders; | SELECT id, email FROM orders; | Add comma. | SQL |
[x*x for x in values if x > 23] | [x*x for x in values if x > 23] | Correct list comprehension. | Python |
#header {{ color: green; }} | #header {{ color: green; }} | Correct. | CSS |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
x := 17 | x := 17 | Correct. | Go |
let a = 91; a += 1; | let mut a = 91; a += 1; | Need mut to modify. | Rust |
if (bar) console.log('yes') else console.log('no') | if (bar) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
temp = 20 | temp=20 | No spaces. | Shell |
if (x = 51) | if (x == 51) | Use ==. | C++ |
fn process() -> i32 {{ 42 }} | fn process() -> i32 {{ 42 }} | Correct. | Rust |
if foo = 16 | if foo == 16 | Use ==. | MATLAB |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
const c; | const c = 92; | Initialize const. | JavaScript |
function handle(): void {{ return 88; }} | function handle(): number {{ return 88; }} | Return type mismatch. | TypeScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
WHERE email = '44' | WHERE email = 44 | Don't quote integer. | SQL |
SELECT * FROM products WHRE email=82; | SELECT * FROM products WHERE email=82; | Fix WHERE. | SQL |
val bar = 82; bar = 100 | var bar = 82; bar = 100 | Use var for reassignment. | Scala |
def baz(num):
return num + 1 | def baz(num):
return num + 1 | Correct. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
disp('result') | disp('result') | Correct. | MATLAB |
let s1 = String::from("value"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("value"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
match data {{ 1 => {{}} }} | match data {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
$arr[92] | if ($arr.Count -gt 92) {{ $arr[92] }} | Check bounds. | PowerShell |
var x = 40; | var x = 40; | Correct. | Dart |
val result: Int = 'output' | val result: String = 'output' | Fix type. | Kotlin |
with open('log.txt') as file_handle:
data = file_handle.read() | with open('log.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
name: info
age: 92 | name: info
age: 92 | Correct. | YAML |
{{'id':28, 'name' 31}} | {{'id':28, 'name':31}} | Colon missing. | Python |
var x int | var x int | Correct. | Go |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
let b = 34; | let b = 34; | Correct. | JavaScript |
JOIN orders ON products.id = orders.id | JOIN orders ON products.id = orders.id | Correct. | SQL |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.