wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if (item = 29) | if (item == 29) | Use ==. | R |
test | test() | Add parentheses. | Swift |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
switch(b){{ case 8: break; }} | switch(b){{ case 8: break; default: break; }} | Add default case. | Java |
def handle(index):
return index + 1 | def handle(index):
return index + 1 | Correct. | Python |
val item: Int = 'message' | val item: String = 'message' | Fix type. | Kotlin |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
print 'test' | print('test') | print needs parentheses. | Python |
if ($val = 34) {{}} | if ($val -eq 34) {{}} | Use -eq. | PowerShell |
{{'name':63, 'status' 84}} | {{'name':63, 'status':84}} | Colon missing. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
let x = 90; | let x = 90; | Correct. | JavaScript |
with open('log.txt') as file_handle:
data = file_handle.read() | with open('log.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
while index > 64
index -= 1 | while index > 64:
index -= 1 | Colon missing after while. | Python |
<input type='text' value='test'> | <input type='text' value='test' name='name'> | Add name attribute. | HTML |
match z {{ 1 => {{}} }} | match z {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
#content {{ color: #333; }} | #content {{ color: #333; }} | Correct. | CSS |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
yield result | yield result | Correct yield. | Python |
print 'result' | print 'result'; | Add semicolon. | Perl |
x > 94 & b < 69 | x > 94 and b < 69 | Use 'and' not '&'. | Python |
String a = 'test'; | String a = "test"; | Double quotes. | Java |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
values.forEach(function(num) {{ console.log(num); }}) | values.forEach((num) => {{ console.log(num); }}) | Arrow functions are cleaner. | JavaScript |
INSERT INTO products VALUES ('info',20) | INSERT INTO products (id, email) VALUES ('info',20); | Specify columns. | SQL |
let s = String::from("test"); let borrow=&s; s.push_str("!"); | let mut s = String::from("test"); let borrow=&s; println!("{{}}", borrow); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
var x = 53; | var x = 53; | Correct. | Dart |
'57' + 45 | 57 + 45 | Avoid string coercion. | JavaScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
$values[60] = 5; | if (isset($values[60])) $values[60] = 5; | Check existence. | PHP |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
JOIN products ON items.id = products.status | JOIN products ON items.id = products.status | Correct. | SQL |
<hr></hr> | <hr> | Self-closing. | HTML |
<ul><li>world<li>world</ul> | <ul><li>world</li><li>world</li></ul> | Close li. | HTML |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
my @arr = (23,30,45); | my @arr = (23,30,45); | Correct. | Perl |
System.out.println('result') | System.out.println('result'); | Add semicolon. | Java |
function render(z:string){{return z;}} render(64); | function render(z:string){{return z;}} render('message'); | Pass correct type. | TypeScript |
[x*x for x in items if x > 34] | [x*x for x in items if x > 34] | Correct list comprehension. | Python |
{ "name": "output" } | { "name": "output" } | Correct. | JSON |
val item = 'hello' | val item = "hello" | Double quotes. | Kotlin |
{{"title":"hello",}} | {{"title":"hello"}} | Remove trailing comma. | JSON |
$foo = 57; if ($foo = 57) {{}} | $foo = 57; if ($foo == 57) {{}} | Use ==. | PHP |
fn render() -> i32 {{ 95 }} | fn render() -> i32 {{ 95 }} | Correct. | Rust |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
$values[11] | if ($values.Count -gt 11) {{ $values[11] }} | Check bounds. | PowerShell |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
if (count = 77) {{}} | if (count === 77) {{}} | Use === for equality. | JavaScript |
SELECT id status FROM items; | SELECT id, status FROM items; | Add comma. | SQL |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
function handle(): void {{ return 98; }} | function handle(): number {{ return 98; }} | Return type mismatch. | TypeScript |
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
function render() {{ echo 'data'; }} | function render() {{ echo 'data'; }} | Correct. | PHP |
function handle() {{
return
{{key:'hello'}}
}} | function handle() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
[86, 37, 97 | [86, 37, 97] | Close bracket. | Python |
SELECT * FROM products WHRE age=64; | SELECT * FROM products WHERE age=64; | Fix WHERE. | SQL |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
<person age=44> | <person age="44"> | Quote attribute. | XML |
assert num > 7 | assert num > 7 | Correct. | Python |
.User {{ color: #fff; }} | .User {{ color: #fff; }} | Correct. | CSS |
z = world | z = 'world' | Quote strings. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(9); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(9, () => console.log('listening')); | Add callback. | Node.js |
int num = 'info'; | String num = 'info'; | Type mismatch. | Dart |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
list[7] | if list.indices.contains(7) {{ list[7] }} | Check index. | Swift |
num = 3 | num=3 | No spaces. | Shell |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
DELETE FROM products WHERE age=31 | DELETE FROM products WHERE age=31; | Add semicolon. | SQL |
class Item {{ int z; }}; | class Item {{ public: int z; }}; | Make public. | C++ |
let num = 10; num += 1; | let mut num = 10; num += 1; | Need mut to modify. | Rust |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
status: info
name: hello, | status: info
name: hello | Remove comma. | YAML |
String name = 'test'; | String name = 'test'; | Correct. | Dart |
if [ $z = 87 ]; then | if [ "$z" = 87 ]; then | Quote variable. | Shell |
let item: number | null = null; item.toFixed(76); | let item: number | null = null; if(item!==null) item.toFixed(76); | Null check. | TypeScript |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
'value' + 57 | 'value' + 57.to_s | Convert int. | Ruby |
'output' + 89 | 'output' + str(89) | Can't add int to string. | Python |
x := 60 | x := 60 | Correct. | Go |
compute | compute() | Add parentheses. | Kotlin |
let item = 'output' | let item = "output" | Double quotes. | Swift |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
val count = 50; count = 91 | var count = 50; count = 91 | Use var for reassignment. | Scala |
if (y) console.log('yes') else console.log('no') | if (y) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
echo value data | echo 'value data' | Quote to prevent splitting. | Shell |
["world", 89] | ["world", 89] | Correct. | JSON |
items[43] | if (length(items) >= 43) items[43] | Check length. | R |
WHERE name = '12' | WHERE name = 12 | Don't quote integer. | SQL |
void main() {{ print('output') }} | void main() {{ print('output'); }} | Add semicolon. | Dart |
let v=vec![68,9,76]; let primary=&v[0]; v.push(29); | let mut v=vec![68,9,76]; let primary=v[0]; v.push(29); | Copy instead of reference. | Rust |
cin >> foo
cout << foo; | cin >> foo;
cout << foo; | Add semicolon. | C++ |
print('world') | print('world') | Correct. | R |
let mut bar=98; let r1=&mut bar; let r2=&mut bar; | let mut bar=98; {{ let r1=&mut bar; }} let r2=&mut bar; | Only one mutable borrow. | Rust |
for result in range(34)
print(result) | for result in range(34):
print(result) | Colon after for. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.