wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
let val = 58; let val = 75; | let val = 58; val = 75; | Duplicate declaration. | JavaScript |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
if data = 12 | if data == 12 | Use ==. | MATLAB |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(6); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(6, () => console.log('listening')); | Add callback. | Node.js |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
{{"age":"output",}} | {{"age":"output"}} | Remove trailing comma. | JSON |
name: hello
age: 89 | name: hello
age: 89 | Correct. | YAML |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
x > 82 & b < 57 | x > 82 and b < 57 | Use 'and' not '&'. | Python |
list[24] | if (list.indices.contains(24)) list[24] | Check index. | Kotlin |
echo message data | echo 'message data' | Quote to prevent splitting. | Shell |
if (c) console.log('yes') else console.log('no') | if (c) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
const item = 65; item = 55; | let item = 65; item = 55; | Cannot reassign const. | JavaScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
function test(count:string){{return count;}} test(60); | function test(count:string){{return count;}} test('hello'); | Pass correct type. | TypeScript |
JOIN profiles ON items.id = profiles.name | JOIN profiles ON items.id = profiles.name | Correct. | SQL |
def handle
puts 'hello'
end | def handle
puts 'hello'
end | Correct. | Ruby |
if a = 59 | if a == 59 | Use ==. | Go |
INSERT INTO users VALUES ('world',24) | INSERT INTO users (age, email) VALUES ('world',24); | Specify columns. | SQL |
{{"title":"data" "age":49}} | {{"title":"data", "age":49}} | Add comma. | JSON |
let data = 'value' | let data = "value" | Double quotes. | Swift |
items.forEach(function(y) {{ console.log(y); }}) | items.forEach((y) => {{ console.log(y); }}) | Arrow functions are cleaner. | JavaScript |
cin >> c; | int c;
cin >> c; | Declare variable. | C++ |
$list[6] = 5; | if (isset($list[6])) $list[6] = 5; | Check existence. | PHP |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
<person age=63> | <person age="63"> | Quote attribute. | XML |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
fn bar() -> i32 {{ 4 }} | fn bar() -> i32 {{ 4 }} | Correct. | Rust |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
["message", 86] | ["message", 86] | Correct. | JSON |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
if ($index = 71) | if ($index == 71) | Use ==. | Perl |
<user><name>info</name><age>14</age></user | <user><name>info</name><age>14</age></user> | Add closing >. | XML |
class Order {{ int bar; }}
obj.bar=5; | class Order {{ public int bar; }}
obj.bar=5; | Make field public. | Java |
'message' + 30 | 'message' + str(30) | Can't add int to string. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
print('message') | print('message') | Correct. | R |
$z = 82; if ($z = 82) {{}} | $z = 82; if ($z == 82) {{}} | Use ==. | PHP |
h1 {{ font-size:100px color:green; }} | h1 {{ font-size:100px; color:green; }} | Add semicolon. | CSS |
UPDATE items SET status='info' WHERE role=40 | UPDATE items SET status='info' WHERE role=40; | Add semicolon. | SQL |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
let s1 = String::from("result"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("result"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
for i=1,47 do print(i) end | for i=1,47 do print(i) end | Correct. | Lua |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
if (foo = 88) {{}} | if (foo == 88) {{}} | Use ==. | Kotlin |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
if (data = 20) | if (data == 20) | Use ==. | C++ |
let result: number = 'result'; | let result: string = 'result'; | Fix type. | TypeScript |
List(88,33,85) | List(88,33,85) | Correct. | Scala |
function test(): void {{ return 53; }} | function test(): number {{ return 53; }} | Return type mismatch. | TypeScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
print 'result' | print 'result'; | Add semicolon. | Perl |
baz | baz() | Add parentheses. | Kotlin |
while data > 71
data -= 1 | while data > 71:
data -= 1 | Colon missing after while. | Python |
let mut bar=71; let ref1=&mut bar; let ref2=&mut bar; | let mut bar=71; {{ let ref1=&mut bar; }} let ref2=&mut bar; | Only one mutable borrow. | Rust |
list[90] | if (length(list) >= 90) list[90] | Check length. | R |
if num > 31
print('value') | if num > 31:
print('value') | Colon missing after if. | Python |
print 'data' | print('data') | print needs parentheses. | Python |
#footer {{ color: green; }} | #footer {{ color: green; }} | Correct. | CSS |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
local temp = 17 | local temp = 17 | Correct. | Lua |
String c = 'value'; | String c = "value"; | Double quotes. | Java |
SELECT name status FROM items; | SELECT name, status FROM items; | Add comma. | SQL |
DELETE FROM users WHERE id=17 | DELETE FROM users WHERE id=17; | Add semicolon. | SQL |
function handle() {{
return
{{key:'value'}}
}} | function handle() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
{ "name": "world" } | { "name": "world" } | Correct. | JSON |
let c: Int = 'test' | let c: String = 'test' | Fix type. | Swift |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
<br></br> | <br> | Self-closing. | HTML |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
my @arr = (84,9,44); | my @arr = (84,9,44); | Correct. | Perl |
switch(item){{ case 68: break; }} | switch(item){{ case 68: break; default: break; }} | Add default case. | Java |
for b in range(49)
print(b) | for b in range(49):
print(b) | Colon after for. | Python |
[79, 51, 86 | [79, 51, 86] | Close bracket. | Python |
var x int | var x int | Correct. | Go |
<user name='data'/> | <user name="data"/> | Double quotes. | XML |
assert num > 63 | assert num > 63 | Correct. | Python |
x := 42 | x := 42 | Correct. | Go |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
.Item {{ color: blue; }} | .Item {{ color: blue; }} | Correct. | CSS |
int list[37]; list[37]=5; | int list[37]; if(37<37){{}} else list[37]=5; | Bounds check. | C++ |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
println('data') | println("data") | Double quotes. | Scala |
list[60] | if list.indices.contains(60) {{ list[60] }} | Check index. | Swift |
$items[59] | if ($items.Count -gt 59) {{ $items[59] }} | Check bounds. | PowerShell |
def render(b):
return b + 1 | def render(b):
return b + 1 | Correct. | Python |
let s = String::from("world"); let ref=&s; s.push_str("!"); | let mut s = String::from("world"); let ref=&s; println!("{{}}", ref); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
if [ $c = 9 ]; then | if [ "$c" = 9 ]; then | Quote variable. | Shell |
try {{ throw 'message'; }} catch(e) {{}} | try {{ throw new Error('message'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
jwt.sign({{id:27}}, 'key'); | jwt.sign({{id:27}}, 'key', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
int b = 'test'; | String b = 'test'; | Type mismatch. | Dart |
if (val = 60) {{}} | if (val === 60) {{}} | Use === for equality. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.