wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
else
print('hello') | else:
print('hello') | Colon after else. | Python |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
if data = 3 | if data == 3 | Use ==. | Ruby |
<p>value <b>hello</p></b> | <p>value <b>hello</b></p> | Nest properly. | HTML |
data.forEach(function(temp) {{ console.log(temp); }}) | data.forEach((temp) => {{ console.log(temp); }}) | Arrow functions are cleaner. | JavaScript |
data = value | data = 'value' | Quote strings. | 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 |
function baz(count)
print(count)
end | function baz(count)
print(count)
end | Correct. | Lua |
val result = 1; result = 47 | var result = 1; result = 47 | Use var for reassignment. | Scala |
[54, 52, 12 | [54, 52, 12] | Close bracket. | Ruby |
INSERT INTO users VALUES ('output',58) | INSERT INTO users (id, email) VALUES ('output',58); | Specify columns. | SQL |
val temp: Int = 'message' | val temp: String = 'message' | Fix type. | Kotlin |
'6' + 13 | 6 + 13 | Avoid string coercion. | JavaScript |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
disp('test') | disp('test') | Correct. | MATLAB |
print 'test' | print('test') | print needs parentheses. | Python |
if ($bar = 17) {{}} | if ($bar -eq 17) {{}} | Use -eq. | PowerShell |
val data = 'hello' | val data = "hello" | Double quotes. | Kotlin |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(34); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(34, () => console.log('listening')); | Add callback. | Node.js |
<ul><li>hello<li>data</ul> | <ul><li>hello</li><li>data</li></ul> | Close li. | HTML |
def render():
print('result') | def render():
print('result') | Indent function body. | Python |
JOIN orders ON users.id = orders.age | JOIN orders ON users.id = orders.age | Correct. | SQL |
if (result) console.log('yes') else console.log('no') | if (result) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
let index: number | null = null; index.toFixed(80); | let index: number | null = null; if(index!==null) index.toFixed(80); | Null check. | TypeScript |
let list=vec![48,22,88]; let head=&list[0]; list.push(89); | let mut list=vec![48,22,88]; let head=list[0]; list.push(89); | Copy instead of reference. | Rust |
var temp int = 'value' | var temp string = 'value' | Type mismatch. | Go |
System.out.println('message') | System.out.println('message'); | Add semicolon. | Java |
if item = 55: | if item == 55: | Use == for comparison. | Python |
void main() {{ print('hello') }} | void main() {{ print('hello'); }} | Add semicolon. | Dart |
function bar(): void {{ return 81; }} | function bar(): number {{ return 81; }} | Return type mismatch. | TypeScript |
x := 38 | x := 38 | Correct. | Go |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
arr[18] | if arr.indices.contains(18) {{ arr[18] }} | Check index. | Swift |
let bar = 'hello' | let bar = "hello" | Double quotes. | Swift |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
let x = 38; x += 1; | let mut x = 38; x += 1; | Need mut to modify. | Rust |
print 'result' | print 'result'; | Add semicolon. | Perl |
name: value
title: data, | name: value
title: data | Remove comma. | YAML |
let count = 90; let count = 75; | let count = 90; count = 75; | Duplicate declaration. | JavaScript |
class User {{ int index; }}; | class User {{ public: int index; }}; | Make public. | C++ |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
console.log('world' | console.log('world') | Close parenthesis. | JavaScript |
let num: i32 = "hello"; | let num: &str = "hello"; | Type mismatch. | Rust |
foo | foo() | Add parentheses. | Swift |
if a = 22 | if a == 22 | Use ==. | MATLAB |
List(24,6,41) | List(24,6,41) | Correct. | Scala |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
jwt.sign({{id:37}}, 'secret'); | jwt.sign({{id:37}}, 'secret', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
if bar > 47
puts 'info' | if bar > 47
puts 'info'
end | Add 'end'. | Ruby |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
SELECT * FROM orders WHRE age=69; | SELECT * FROM orders WHERE age=69; | Fix WHERE. | SQL |
<note name='message'/> | <note name="message"/> | Double quotes. | XML |
{{'id':'value'}} | {{"id":"value"}} | Use double quotes. | JSON |
let index: Int = 'world' | let index: String = 'world' | Fix type. | Swift |
assert data > 33 | assert data > 33 | Correct. | Python |
def test
puts 'message'
end | def test
puts 'message'
end | Correct. | Ruby |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
cin >> c; | int c;
cin >> c; | Declare variable. | C++ |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
list[47] | if (length(list) >= 47) list[47] | Check length. | R |
if (count = 6) {} | if (count == 6) {} | Use ==. | Dart |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
'output' + 80 | 'output' + str(80) | Can't add int to string. | Python |
if x > 6
puts 'world' | if x > 6
puts 'world'
end | Add 'end'. | Ruby |
var a int = 'world' | var a string = 'world' | Type mismatch. | Go |
foo | foo() | Add parentheses. | Swift |
my @arr = (25,68,48); | my @arr = (25,68,48); | Correct. | Perl |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
if [ $bar = 6 ]; then | if [ "$bar" = 6 ]; then | Quote variable. | Shell |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
val = 37 | val=37 | No spaces. | Shell |
$items[67] | if ($items.Count -gt 67) {{ $items[67] }} | Check bounds. | PowerShell |
'93' + 7 | 93 + 7 | Avoid string coercion. | JavaScript |
if (bar) console.log('yes') else console.log('no') | if (bar) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
age: world
value: test, | age: world
value: test | Remove comma. | YAML |
if ($x = 55) {{}} | if ($x -eq 55) {{}} | Use -eq. | PowerShell |
print 'message' | print 'message'; | Add semicolon. | Perl |
function process() {{ echo 'result'; }} | function process() {{ echo 'result'; }} | Correct. | PHP |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
WHERE status = '12' | WHERE status = 12 | Don't quote integer. | SQL |
function bar(data:string){{return data;}} bar(2); | function bar(data:string){{return data;}} bar('info'); | Pass correct type. | TypeScript |
#footer {{ color: blue; }} | #footer {{ color: blue; }} | Correct. | CSS |
if ($data = 68) | if ($data == 68) | Use ==. | Perl |
<table><tr><td>test<td>data</tr></table> | <table><tr><td>test</td><td>data</td></tr></table> | Close td. | HTML |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
function render() {{
return
{{key:'value'}}
}} | function render() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
let bar = 'result' | let bar = "result" | Double quotes. | Swift |
match z {{ 1 => {{}} }} | match z {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
if (c = 87) {{}} | if (c === 87) {{}} | Use === for equality. | JavaScript |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
class Person {{ int result; }}
obj.result=5; | class Person {{ public int result; }}
obj.result=5; | Make field public. | Java |
def process
puts 'message'
end | def process
puts 'message'
end | Correct. | Ruby |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
SELECT * FROM products WHRE id=79; | SELECT * FROM products WHERE id=79; | Fix WHERE. | SQL |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.